You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
6
6
7
7
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.
8
8
@@ -60,13 +60,13 @@ Let's go through and explain what each part means and refers to.
60
60
61
61
### src-path
62
62
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.
64
64
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`.
66
66
67
67
### test-path
68
68
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.
70
70
71
71
### matches
72
72
@@ -78,12 +78,42 @@ If you are working with the standard Laravel file structure, you'll want to chan
78
78
79
79
### matches-dev-test
80
80
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.
82
82
83
83
## Debugging
84
84
85
85
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.
86
86
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.
@@ -92,7 +122,7 @@ Until php includes a spec for function autoloading, creating and using standard
92
122
93
123
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.
94
124
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
0 commit comments