Skip to content

Clean up and clarify autoloader section in Sf2 vs sf1 comparison chapter #2331

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
caponica opened this issue Mar 21, 2013 · 2 comments
Closed
Labels
actionable Clear and specific issues ready for anyone to take them. bug
Milestone

Comments

@caponica
Copy link
Contributor

At the moment the section about Autoloading in the Sf2 vs sf1 comparison chapter is a bit muddled up. It has been partly updated to deal with the changes that came with using composer from Sf2.1 but still references /vendor/bundles (which no longer exists).

Quote from latest version:

As mentioned before, for the autoloader to work, it needs to know that the Sensio
namespace lives in the vendor/bundles directory and that...

As well as this, the explanation doesn't really make it clear how Symfony / composer knows that the namespace of Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle maps to vendor/sensio/framework-extra-bundle/Sensio/Bundle/FrameworkExtraBundle/SensioFrameworkExtraBundle.php.

The last part of the path is easy enough - but how does composer figure out the vendor/sensio/framework-extra-bundle part of the path?

I'm new at this, but I guess that somewhere the Sensio namespace is mapped to vendor/sensio/framework-extra-bundle/Sensio - but where is this done? Or have I completely misunderstood?

The filename is cookbook/symfony1.rst and the section header is "Autoloading". See also some brief comments in #2324 .

@wouterj
Copy link
Member

wouterj commented Mar 21, 2013

This way of autoloading is no longer required; Composer does all the autoloading tasks for all packages that are installed with Composer.

In some very specific cases, where you put files outside any of the registered directories (in SE, these are src, app and vendor), you should worry about registering the autoloading. This is done in the composer.json file (documentation about that).

Basically, we should remove this namespace registering stuff from the 2.1 branch and replace it with some note which says that it's done by Composer and if you use some other dir, you need to edit your composer.json file + a link to their docs.

@weaverryan
Copy link
Member

Wouter made several changes and improvements in #2867, so I'm going to close this! If there's anything else missing or not quite right, let us know.

Thanks everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actionable Clear and specific issues ready for anyone to take them. bug
Projects
None yet
Development

No branches or pull requests

3 participants