4

I am working on a bundle in which I use the Doctrine CouchDB ODM. How does one autoload and register the namespaces from within a bundle? Here are the relevant working lines from app/autoload.php that I need to move:

use Symfony\Component\ClassLoader\UniversalClassLoader;

$loader->registerNamespaces(array(
    // ...
    'Doctrine\\CouchDB' => __DIR__.'/../vendor/doctrine-odm/lib',
    'Doctrine\\ODM\\CouchDB' => __DIR__.'/../vendor/doctrine-odm/lib',
));

Thank you!

5
  • Why exactly do you need to move them? Commented Nov 30, 2011 at 16:24
  • You usually don't have to do it. Just put the declarations in your app/autoload.php and, if the bundle will be available to the public, add the info to your README. Commented Nov 30, 2011 at 16:41
  • The idea was to eliminate the need for folks implementing this bundle to add stuff to their app. @alessandro1997 implies that adding to app/autoload.php is the only way it's done, which would explain why I haven't found any instructions! Commented Nov 30, 2011 at 16:54
  • An interesting question, but I'd argue that it's better to keep namespace declarations in autoload.php to avoid possible duplicates if they were defined within the bundles directly. An unlikely scenario, but still possible, and would be annoying to debug :) Commented Nov 30, 2011 at 20:19
  • 1
    Composer is the tool that was developed to deal with this: knplabs.com/blog/symfony2-with-composer Commented Apr 3, 2012 at 13:36

1 Answer 1

2

Composer was added to address this issue: http://knplabs.com/blog/symfony2-with-composer

Sign up to request clarification or add additional context in comments.

2 Comments

The provided link no longer works. Can you please add/paste the relevant answer here?
Heh, this is a bit obsolete, as Composer has become the PHP community standard for dependency management, supplanting PEAR getcomposer.org

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.