Skip to content

Commit 988b027

Browse files
committed
Adjusting documentation
Signed-off-by: RJ Garcia <[email protected]>
1 parent 607f79d commit 988b027

File tree

1 file changed

+36
-6
lines changed

1 file changed

+36
-6
lines changed

README.md

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
![PHP Requirements](https://img.shields.io/badge/php-%5E7.1-8892BF.svg)
44

5-
Php inc is a composer plugin for automatically including certain files into composer's `autoload` and `autoload-dev` `files` config. Given a set of file matchers, on the the `dump-autoload` event, php-inc will automatically include any matched files into the dumped autoloaded files.
5+
Php inc is a composer plugin for automatically including certain files into composer's `autoload` and `autoload-dev` `files` config. Given a set of file matchers, on the the `dump-autoload` event, php-inc will automatically include any matched files into the dumped autoloaded files.
66

77
This ameliorates the issues that come about when you want to include certain files that contain functions or maybe multiple classes but don't want to constantly update the composer autoload files configuration which can get hard to deal with when you start including more files.
88

@@ -60,13 +60,13 @@ Let's go through and explain what each part means and refers to.
6060

6161
### src-path
6262

63-
`src-path` will determine the path to your source code where any autoload files will be searched in.
63+
`src-path` will determine the path to your source code where any autoload files will be searched in.
6464

65-
If you are working with the standard Laravel file structure, you'll want to change the src-path to `app` instead of `src`.
65+
If you are working with the standard Laravel file structure, you'll want to change the src-path to `app` instead of `src`.
6666

6767
### test-path
6868

69-
`test-path` will determine the path to your test code where the autoload-dev files will be searched.
69+
`test-path` will determine the path to your test code where the autoload-dev files will be searched.
7070

7171
### matches
7272

@@ -78,12 +78,42 @@ If you are working with the standard Laravel file structure, you'll want to chan
7878

7979
### matches-dev-test
8080

81-
`matches-dev-test` can be any hierarchy of configured matches to determine how you want the test folder to be searched for files to be included in `autoload-dev.files`. The default configuration ensures that all files that start with a lower case file name, have a `php` extension, and are *not* apart of a `Fixtures` directory will be included in the `autoload-dev.files` composer configuration.
81+
`matches-dev-test` can be any hierarchy of configured matches to determine how you want the test folder to be searched for files to be included in `autoload-dev.files`. The default configuration ensures that all files that start with a lower case file name, have a `php` extension, and are *not* apart of a `Fixtures` directory will be included in the `autoload-dev.files` composer configuration.
8282

8383
## Debugging
8484

8585
If you are ever curious what files are being included, you can simply run `composer dump-autoload -v` and view the php-inc output to see which files are being merged with which composer files definition.
8686

87+
## Managing Dependencies
88+
89+
With extended use, you may come into a situation where one file included needs to be loaded before another. If this comes up, the best solution I've found for now is to prefix those files with an `_` and just create a new file named inc.php which loads them in the correct order.
90+
91+
For example:
92+
93+
```
94+
src/a.php
95+
src/b.php
96+
```
97+
98+
`a.php` depends on `b.php` loading first. To enforce loading order, we'd make the following change:
99+
100+
```
101+
src/_a.php
102+
src/_b.php
103+
src/inc.php
104+
```
105+
106+
Where `inc.php` is as follows:
107+
108+
```php
109+
<?php
110+
111+
require_once __DIR__ . '/_b.php';
112+
require_once __DIR__ . '/_a.php';
113+
```
114+
115+
When you run `composer dump-autoload`, only `inc.php` will be included and will make sure to include those files correctly.
116+
87117
## Why is this useful?
88118

89119
https://nikic.github.io/2012/08/10/Are-PHP-developers-functophobic.html
@@ -92,7 +122,7 @@ Until php includes a spec for function autoloading, creating and using standard
92122

93123
This is useful for more than just functions however. There are plenty of cases where one file with multiple definitions would make sense to keep together instead of splitting into several files which clutter the filesystem.
94124

95-
This plugin is an attempt to help php devs who use composer to have the ability to
125+
This plugin is an attempt to help php devs who use composer to have the ability to
96126

97127
## Drawbacks
98128

0 commit comments

Comments
 (0)