-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Conversation
Optimizing the autoloader should not be in the project-level composer.json. This is not a setting that you want to use in development. Such settings should be turned on only in prod environments (and |
To be clear, |
So you recommend nor |
@Pierstoval I never recommend putting them in the project itself (unless you never develop in it). |
I find this argument very interesting: if you delete a class, it shouldn't be used in your application, therefore the In this case, it means that |
@Pierstoval there are case like |
Hmm... That makes me re-think about default autoload optimization in app. I may remove this part in this PR if it sounds too much for the SE. By the way, what about the |
I suppose |
I removed the |
Composer now has a documentation page about optimizing the autoloader for production: https://getcomposer.org/doc/articles/autoloader-optimization.md |
@stof Great! Then, I guess the Symfony documentation about deployment best practices can also link this article from Composer's website, and we can still review explicit PSR-4 autoload rule for AppBundle, I tend to continue thinking it's a good practice 😃 |
@Pierstoval linking to the composer doc from the Symfony one is the plan, yes. But we wanted to have the source of truth in the composer doc itself (as it is not specific to Symfony) |
Then this PR needs to be reviewed 😸 |
Thank you @Pierstoval. |
This PR was merged into the 2.7 branch. Discussion ---------- Improve PSR-4 autoloading by default TL;DR: (updated Marth 3rd) Before, I proposed to use any optimization by default in `composer.json` (complementary to PSR-4 autoload for the AppBundle). I took note of the different arguments and removed loaders optimization because it is not suitable for dev environments, but kept AppBundle PSR-4 explicit load because it encourages PSR-4 best practices of autoload. --- As seen on symfony/demo#490 (and it's certainly a well-known issue for developers using PHP Inspections EA Extended plugin for PHPStorm), having empty namespaces in `psr-4` rules has an impact on performances. Using this by default on the Standard Edition may encourage developers to add PSR-4 rules if they create new namespaces (for example if they want to create bundleless apps or other bundles, or components inside the same app, etc.). What do you think about putting this in the SE? Also, for best autoloading performances, it is recommended to use `classmap-authoritative` options (which adds `optimize-autoloader` implicitly). I added it in the `composer.json` but I'm not sure whether it's the best option to propose to Symfony newcomers (because `composer install` and `update` takes more time to execute). For this have a question: should we recommend `classmap-authoritative` or `optimize-autoloader` (or nothing ❔) by default ? Commits ------- 5f7ef8c Improve PSR-4 autoload by default
TL;DR: (updated Marth 3rd)
Before, I proposed to use any optimization by default in
composer.json
(complementary to PSR-4 autoload for the AppBundle).I took note of the different arguments and removed loaders optimization because it is not suitable for dev environments, but kept AppBundle PSR-4 explicit load because it encourages PSR-4 best practices of autoload.
As seen on symfony/demo#490 (and it's certainly a well-known issue for developers using PHP Inspections EA Extended plugin for PHPStorm), having empty namespaces in
psr-4
rules has an impact on performances.Using this by default on the Standard Edition may encourage developers to add PSR-4 rules if they create new namespaces (for example if they want to create bundleless apps or other bundles, or components inside the same app, etc.).
What do you think about putting this in the SE?
Also, for best autoloading performances, it is recommended to use
classmap-authoritative
options (which addsoptimize-autoloader
implicitly). I added it in thecomposer.json
but I'm not sure whether it's the best option to propose to Symfony newcomers (becausecomposer install
andupdate
takes more time to execute).For this have a question: should we recommend
classmap-authoritative
oroptimize-autoloader
(or nothing ❔) by default ?