propelorm / Propel2

Propel2 is an open-source high-performance Object-Relational Mapping (ORM) for modern PHP
http://propelorm.org/
MIT License
1.26k stars 398 forks source link

Using PSR-4 for model classes #575

Open gharlan opened 10 years ago

gharlan commented 10 years ago

It should be possible to use PSR-4 for generated model classes. Correct me if I'm wrong, but at the moment Propel2 supports PSR-0 only.

willdurand commented 10 years ago

Well, why not...

willdurand commented 10 years ago

It is an improvement, not scheduled yet.

marcj commented 10 years ago

Would actually be nice to have it. @gharlan any chance you can provide a PR?

gossi commented 10 years ago

Actually, in order to get the psr-4 location, composer.json must be read to get the correct location. Bascially, for any psr (psr-0 and psr-4) this would mean an auto-target-location. Propel reads the autoload-part of composer.json and whenever it is possible to match namespaces, the detected location is used. For everything else the target-option is used, kinda as a fallback.

gossi commented 10 years ago

I actually think, this isn't a nice to have, because at the moment, it is required to build your own buildscript around propel that deals with the paths, instead of just run propel from the command line.

vworldat commented 10 years ago

I ran into the same issue today. Using Propel with Symfony2 Bundles installed by composer and configured to use PSR-4 won't work, the generated files end up in the wrong location.

Since it looks like everyone is keen to upgrade to PSR-4 I fear this will become a blocker soon.

marcj commented 10 years ago

I guess a option like --set-namespace-path at the build command would be enough to achieve that (with a configuration possibility as well). At the moment the file path is based on the namespace of the model and IIRC PSR-4 only defines that you're allowed to use different file paths than the namespace of the class.

Default: Propel\Bookstore\Models\Author => ./Propel/Bookstore/Models/Author.php With --set-namespace-path=./Models/ => ./Models/Author.php

vworldat commented 10 years ago

What about specifying the path in the schema next to the namespace?

marcj commented 10 years ago

Yeah, that would be the with a configuration possibility as well :-)

polybuildr commented 8 years ago

Any updates on this issue?

marcj commented 8 years ago

No