Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Commit f10fbb4

Browse files
committed
minor #1048 Improve PSR-4 autoloading by default (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
2 parents 4d28e79 + 5f7ef8c commit f10fbb4

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

composer.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
"type": "project",
55
"description": "The \"Symfony Standard Edition\" distribution",
66
"autoload": {
7-
"psr-4": { "": "src/" }
7+
"psr-4": {
8+
"AppBundle\\": "src/AppBundle"
9+
}
810
},
911
"autoload-dev": {
1012
"files": [ "vendor/symfony/symfony/src/Symfony/Component/VarDumper/Resources/functions/dump.php" ]

0 commit comments

Comments
 (0)