Use PSR-4 everywhere instead of PSR-0 #11190

wants to merge 1 commit into


None yet

5 participants

Symfony member
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #11189
License MIT
@Tobion Tobion Use PSR-4 everywhere instead of PSR-0
@Taluu Taluu commented on the diff Jun 20, 2014
@@ -78,7 +78,7 @@
"egulias/email-validator": "1.1.0"
"autoload": {
- "psr-0": { "Symfony\\": "src/" },
+ "psr-4": { "Symfony\\": "src/Symfony/" },
Taluu Jun 20, 2014

I'm not sure the root composer.json should change to PSR-4. It is valid for the components' and bundles', because it replaces the deprecated composer's target-dir option, but on the root, as there is no such option enabled...

Tobion Jun 20, 2014 Symfony member

What's the disadvantage of using PSR-4? I don't thnk we are going to create PEAR-like classes in symfony, do you?

Taluu Jun 20, 2014

Well, both of these standards are valid IMO (even though I also prefer the PSR-4). And your change is valid.

But here, on the root, we have a PSR-0 structure (the src is in the src directory, which have a Symfony subdir, which have a Component, Bridge and Bundlesubdirectory, ... etc), when in the bundles / components, we have a PSR-4 structure (the sources are on the same level as the composer.json).

I'm just not sure if there is a gain of performances (it depends if the psr-4 stuff is loaded before or after the psr-0 stuff)

sstok Jun 21, 2014

#11189 (comment)
"the PSR-4 rules are applied before the PSR-0 ones"

stof Jun 21, 2014 Symfony member

note that the advantage only appears in dev though. In prod, you should dump an optimized autoloader with composer, which will then never reach the PSR-4 or the PSR-0 logic normally but only the classmap

Symfony member

👍 - and I sent #11199 that fixes the test suite. Closing this since the other one includes this PR.

@Seldaek Seldaek closed this Jun 22, 2014
@Tobion Tobion deleted the Tobion:psr-4 branch Jun 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment