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
Copy file name to clipboardExpand all lines: MIGRATION.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -12,15 +12,15 @@ None
12
12
13
13
### Backward Incompatible Changes
14
14
15
-
- The value of `ignore-paths` is no longer a pattern, it is now relative to the `composer.json` file. The `{vendor}` placeholder can be used as a placeholder for the absolute path to the vendor directory.
15
+
- The paths defined by the `include` and `exclude` directives are relative to the `composer.json` file. The `{vendor}` placeholder is replaced by the absolute path to the vendor directory.
16
16
17
17
### Deprecated Features
18
18
19
-
None
19
+
- The `ignore-paths` directive has been replaced by `exclude`.
20
20
21
21
### Other Changes
22
22
23
-
None
23
+
- The plugin no longer use a file cache by default. To persist a cache between runs, set the environment variable `COMPOSER_ATTRIBUTE_COLLECTOR_USE_CACHE` to `1`, `yes`, or `true`.
The plugin is currently experimental and its interface subject to change. Also, it only supports
81
-
classand method targets. Please [contribute](CONTRIBUTING.md) if you're interested in shaping its
82
-
future.
85
+
The plugin is currently experimental and its interface subject to change. At the moment, it only
86
+
supports class, method, and property targets. Please [contribute](CONTRIBUTING.md) if you're interested in
87
+
shaping its future.
83
88
84
-
**Note:** The plugin creates a `.composer-attribute-collector` directory to store caches, you might
85
-
want to add it to your `.gitignore` file.
86
89
87
90
88
-
####Sample configuration
91
+
### Sample configuration
89
92
90
-
The plugin only inspects paths and files specified in the configuration, that's usually your "src"
91
-
directory. Add this section to your `composer.json` file to enable the generation of the attributes
92
-
file on autoload dump.
93
+
The plugin only inspects paths and files specified in the configuration with the direction
94
+
`include`. That's usually your "src" directory. Add this section to your `composer.json` file to
95
+
enable the generation of the attributes file on autoload dump.
93
96
94
97
Check the [Configuration options](#configuration) for more details.
95
98
@@ -107,28 +110,10 @@ Check the [Configuration options](#configuration) for more details.
107
110
108
111
109
112
113
+
### Autoloading
110
114
111
-
## Frequently Asked Questions
112
-
113
-
**Do I need to generate an optimized autoloader?**
114
-
115
-
You don't need to generate an optimized autoloader for this to work. The plugin uses code similar
116
-
to Composer to find classes. Anything that works with Composer should work with the plugin.
117
-
118
-
**Can I use the plugin during development?**
119
-
120
-
Yes, you can use the plugin during development, but keep in mind the attributes file is only
121
-
generated after the autoloader is dumped. If you modify attributes you'll have to run
122
-
`composer dump` to refresh the attributes file.
123
-
124
-
As a workaround you could have watchers on the directories that contain classes with attributes to
125
-
run `XDEBUG_MODE=off composer dump` when you make changes. [PhpStorm offers file watchers][phpstorm-watchers]. You could also use [spatie/file-system-watcher][], it only requires PHP.
126
-
127
-
128
-
129
-
## Autoloading
130
-
131
-
You can require the attributes file as shown in the usage example, but it's preferable to use Composer's autoloading feature:
115
+
You can require the attributes file using `require_once 'vendor/attributes.php';` but you might
116
+
prefer using Composer's autoloading feature:
132
117
133
118
```json
134
119
{
@@ -144,7 +129,7 @@ You can require the attributes file as shown in the usage example, but it's pref
144
129
145
130
## Configuration
146
131
147
-
### Excluding paths or files ([root-only][])
132
+
### Including paths or files ([root-only][])
148
133
149
134
Use the `include` property to define the paths or files to inspect for attributes. Without this
150
135
property, the attributes file will be empty.
@@ -177,29 +162,61 @@ replaced with the path to the vendor folder.
177
162
"extra": {
178
163
"composer-attribute-collector": {
179
164
"exclude": [
180
-
"path-or-file/to/ignore"
165
+
"path-or-file/to/exclude"
181
166
]
182
167
}
183
168
}
184
169
}
185
170
```
186
171
172
+
### Cache discoveries between runs
187
173
174
+
The plugin is able to maintain a cache to reuse discoveries between runs. To enable the cache,
175
+
set the environment variable `COMPOSER_ATTRIBUTE_COLLECTOR_USE_CACHE` to `1`, `yes`, or `true`.
176
+
Cache items are persisted in the `.composer-attribute-collector` directory, you might want to add
177
+
it to your `.gitignore` file.
188
178
189
-
## Test drive with a Symfony app
190
179
191
-
You can try the plugin with a fresh installation of Symfony.
192
180
193
-
Use the `symfony` command to create a new project. If you don't have it yet, you can [download it](https://symfony.com/download).
181
+
## Frequently Asked Questions
182
+
183
+
**Do I need to generate an optimized autoloader?**
184
+
185
+
You don't need to generate an optimized autoloader for this to work. The plugin uses code similar
186
+
to Composer to find classes. Anything that works with Composer should work with the plugin.
187
+
188
+
**Can I use the plugin during development?**
194
189
195
-
```bash
196
-
symfony new --webapp my_project
190
+
Yes, you can use the plugin during development, but keep in mind the attributes file is only
191
+
generated after the autoloader is dumped. If you modify attributes you'll have to run
192
+
`composer dump` to refresh the attributes file.
193
+
194
+
As a workaround you could have watchers on the directories that contain classes with attributes to
195
+
run `XDEBUG_MODE=off composer dump` when you make changes. [PhpStorm offers file watchers][phpstorm-watchers]. You could also use [spatie/file-system-watcher][], it only requires PHP. If the plugin is too slow for your liking,
196
+
try running the command with `COMPOSER_ATTRIBUTE_COLLECTOR_USE_CACHE=yes`, it will enable caching
197
+
and speed up consecutive runs.
198
+
199
+
200
+
201
+
## Test drive with the Symfony Demo
202
+
203
+
You can try the plugin with a fresh installation of the [Symfony Demo Application](https://github.com/symfony/demo).
204
+
205
+
After you followed the instruction to install the demo, get into the project's directory and install the plugin. You'll be asked if you trust the plugin and wish to activate it. If you wish to continue, choose `y`.
The plugin should have generated the file `vendor/attributes.php`. It should look something like
222
-
this excerpt:
236
+
You should see log messages similar to this:
237
+
238
+
```
239
+
Generating autoload files
240
+
Generating attributes file
241
+
Generated attributes file in 9.137 ms
242
+
Generated autoload files
243
+
```
244
+
245
+
The plugin should have generated the file `vendor/attributes.php`. Let's see if we can get the controller methods tagged as routes. Create a PHP file with the following content and run it:
223
246
224
247
```php
225
248
<?php
226
249
227
-
// attributes.php @generated by https://github.com/olvlvl/composer-attribute-collector
[ ['lint:yaml', 'Lint a YAML file and outputs encountered errors'], \Symfony\Component\Yaml\Command\LintCommand::class ],
235
-
[ ['server:dump', 'Start a dump server that collects and displays dumps in a single place'], \Symfony\Component\VarDumper\Command\ServerDumpCommand::class ],
236
-
[ ['debug:validator', 'Display validation constraints for classes'], \Symfony\Component\Validator\Command\DebugCommand::class ],
237
-
[ ['translation:pull', 'Pull translations from a given provider.'], \Symfony\Component\Translation\Command\TranslationPullCommand::class ],
0 commit comments