Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

Conversation

Tobion
Copy link
Contributor

@Tobion Tobion commented Jun 20, 2014

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #11189
License MIT

@@ -78,7 +78,7 @@
"egulias/email-validator": "1.1.0"
},
"autoload": {
"psr-0": { "Symfony\\": "src/" },
"psr-4": { "Symfony\\": "src/Symfony/" },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Seldaek
Copy link
Member

Seldaek commented Jun 22, 2014

👍 - 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 psr-4 branch June 22, 2014 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants