Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't generate entities after psr-0 to psr-4 change

I changed the psr-0 autoloading to psr-4 for a few of my bundles. Now, when I try to generate entities with the app/console command, it gives me

Can't find base path for "MbDbFooBundle" (path: "/home/roland/projects/rolandtest/mbmbisbundle/Symfony/vendor/mb/mb-db-foo-bundle", destination: "/home/roland/projects/rolandtest/mbmbisbundle/Symfony/vendor/mb/mb-db-foo-bundle").

At first I thought it would be a problem with the generated autoloaders. But when I do a new clone of my project, and then run composer update to complete the vendors, it still gives me this error.

like image 505
rolandow Avatar asked Mar 05 '14 13:03

rolandow


People also ask

What is the difference between PSR-0 and PSR 4?

PSR-0, also known as the Autoloading Standard, prescribes that classes and namespaces in PHP should match the directory and file structure, and vice-versa. PSR-4 allows specifying a namespace prefix for a given directory explicitly.

What is psr4 autoloading Standard How is it different from psr0?

This PSR describes a specification for autoloading classes from file paths. It is fully interoperable, and can be used in addition to any other autoloading specification, including PSR-0. This PSR also describes where to place files that will be autoloaded according to the specification.


1 Answers

In regards to the code generation parts of Doctrine, it doesn't support PSR-4. Only PSR-0. The reason is that it directly converts class/namespace paths to filesystem paths (e.g., converting \ to /). This doesn't work for PSR-4 because it allows for namespaces that don't directly correlate with filesystem paths.

https://github.com/doctrine/DoctrineBundle/issues/282

like image 132
John Pancoast Avatar answered Sep 30 '22 06:09

John Pancoast