I used the Doctrine autoloader in Doctrine\Common\ClassLoader, because I
then can have classnames with an underscore. The Composer autoloader is
almost the same, but completely PSR-0 compliant, so underscores in the
classnames are translated to directory-separators. I'm going to switch to
PSR-4 autoloading, because I want to get rid of that "vendor" folder: that
sounds like selling something and is a bit inappropriate IMHO to all the
hard work in open source projects. I then also have more flexibility not
having to use the whole nested set of folders for a nested set of
namespaces.
I used the Composer autoloader to autoload the Doctrine autoloader (might
not be the best thing, but that's how it grew from first using Composer's
autoloader and later also Doctrine's):
- to use the Composer autoloader: require_once JPATH_LIBRARIES .
"/vendor/autoload.php";
- to use the Doctrine autoloader: use Doctrine\Common\ClassLoader; on
top of the file
- register MyNamespace with the Doctrine autoloader:
$doctrineLoader = new
ClassLoader('MyNamespace','Path/To/Namespaces');
$doctrineLoader->register();
This autoloads a MyNamespace\MyClass from
Path/To/Namespaces/MyNamespace/MyClass.php
On Friday, 7 February 2014 10:46:37 UTC+1, Parsifal wrote:
>
> If it is good idea I want to use the same composer autoloader for entities
> rather than implementing a separate autoloader for entities. I am not
> familiar with composer autoloader. Just adding the correct array with
> correct entity directory path to autolad_namespaces.php is enough? Or
> should I care for something else too?
>
--
You received this message because you are subscribed to the Google Groups
"doctrine-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/doctrine-user.
For more options, visit https://groups.google.com/groups/opt_out.