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

Use PSR-4 #673

Closed
wants to merge 1 commit into from
Closed

Use PSR-4 #673

wants to merge 1 commit into from

Conversation

Tobion
Copy link
Contributor

@Tobion Tobion commented Jun 20, 2014

symfony/symfony#11189 for Symfony Standard

@phansys
Copy link

phansys commented Sep 22, 2014

Hi @Tobion.
Note this point at spec about PSR-4:

The fully qualified class name MUST have a top-level namespace name, also known as a "vendor namespace".

SymfonyRequirements class does not have a namespace, thus I think it must keep leading to PSR-0.
See #712.

@Tobion
Copy link
Contributor Author

Tobion commented Oct 4, 2014

@phansys SymfonyRequirements is not loaded with the autoloader.

@fabpot can we merge this? Considering psr-4 is already used in some symfony parts like SwiftmailerBundle and MonologBundle I would propose to make this consistent in symfony for 2.6

@phansys
Copy link

phansys commented Oct 4, 2014

Well @Tobion, then this change is fine for me.
Thank you!

@Tobion
Copy link
Contributor Author

Tobion commented Nov 2, 2014

@fabpot is there an argument against it?

@derrabus
Copy link
Member

As far as I know, SensioGeneratorBundle is not working correctly, if you switch your Symfony application to PSR-4 with a namespace prefix (filed as sensiolabs/SensioGeneratorBundle#264). Maybe this issue should be fixed first.

@hacfi
Copy link

hacfi commented Mar 24, 2015

👍

@wouterj
Copy link
Member

wouterj commented Apr 2, 2015

-1 for including src/ in the psr-4 autoloading. We should leave that in psr-0 imo

@Tobion
Copy link
Contributor Author

Tobion commented Apr 2, 2015

@wouterj please explain negative votes.

@weaverryan
Copy link
Member

@Tobion Is there any functionality difference at all with this? It seems like I'd still be able to put anything into src/ and have it auto-loaded just like now.

I guess I'm asking, what's the motivation for this? But at the same time, what's the motivation against this if it keeps the same functionality as now?

@wouterj
Copy link
Member

wouterj commented Apr 2, 2015

Hmm, seems like I understood PSR-4 wrongly. As it turns out, empty namespaces will work just like empty namespaces in PSR-0.

However, still having src/Acme/Bundle/BlogBundle instead of src/BlogBundle seems more "PSR-0" than "PSR-4". I'm wondering if we aren't learning people wrong things if we tell them src/Acme/Bundle/BlogBundle is PSR-4.

However, the remaining doubt won't stop me from changing my -1 into a neutral vote.

@Pierstoval
Copy link
Contributor

IMO , the "pros" are that PSR-4 is loaded faster than PSR-0, the "cons" are that PEAR-like structures will be no longer supported with PSR-0.

I'm wondering if we aren't learning people wrong things if we tell them src/Acme/Bundle/BlogBundle is PSR-4.

If PSR-4 is target as "": src/, then src/Acme/Bundle/BlogBundle.php will still be Acme\Bundle\BlogBundle and it won't change.

@Tobion
Copy link
Contributor Author

Tobion commented Apr 12, 2015

Btw, PSR-0 is deprecated by now anyway.

Deprecated - As of 2014-10-21 PSR-0 has been marked as deprecated. PSR-4 is now recommended as an alternative. - http://www.php-fig.org/psr/psr-0/

@Tobion Tobion mentioned this pull request Apr 12, 2015
@Tobion
Copy link
Contributor Author

Tobion commented Apr 12, 2015

Merged #796 into 2.7 as this is also the branch where we adjusted symfony itself to use PSR-4. So this is consistent.

@Tobion Tobion closed this Apr 12, 2015
@Tobion Tobion deleted the patch-1 branch April 12, 2015 14:18
@Tobion
Copy link
Contributor Author

Tobion commented Apr 12, 2015

The lock file needs to be updated so the warning about out-of-sync does't appear. This will be done with the next beta release anyway.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants