Using PSR-4 for model classes #575

Open
gharlan opened this Issue Mar 11, 2014 · 11 comments

Comments

Projects
None yet
6 participants
Contributor

gharlan commented Mar 11, 2014

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.

Owner

willdurand commented Mar 16, 2014

Well, why not...

Owner

willdurand commented Mar 16, 2014

It is an improvement, not scheduled yet.

Owner

marcj commented Apr 16, 2014

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

Contributor

gossi commented Jun 29, 2014

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.

Contributor

gossi commented Jul 20, 2014

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.

Contributor

vworldat commented Aug 2, 2014

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.

Owner

marcj commented Aug 2, 2014

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

Contributor

vworldat commented Aug 2, 2014

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

Owner

marcj commented Aug 2, 2014

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

Any updates on this issue?

Owner

marcj commented Jun 5, 2016

No

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment