|
This post has NOT been accepted by the mailing list yet.
How are people naming their entities/models when using Doctrine 2? Just for argument/discussion sake, assume the namespace is App.
Can/should I go ahead and namespace them (does that even make sense in this context)? <?php namespace App\Model; // @Entity class Test { //@Column $col; } or are you just using the standard? <?php // @Entity class App_Model_Test { //@Column $col; } |
|
They should be namespaced IMO.
Also, the example given here uses namespaces: http://www.doctrine-project.org/blog/doctrine-2-give-me-my-constructor-back |
|
The problem is that Zend_Loader_Autoloader_Resource and, as a consequence, Zend_Application_Module_Autoloader does not support PHP5.3 namespaces for now.
There is an issue related to this problem in ZF Jira: http://framework.zend.com/issues/browse/ZF-8205 (vote for it ;) )
In the meantime, you should use old fashion namespaces with underscores or extend Zend_Loader_Autoloader_Resource to make it support PHP5.3 namespaces (see the proposed patches in Jira issue). The last solution allows to use Doctrine convert mapping tool as it would not let generate a class named Application_Model_User in a file named User.php from an XML or YAML mapping file.
Regards.
On Tue, Mar 23, 2010 at 1:36 AM, David Muir <[hidden email]> wrote:
-- Loïc Frering |
|
the SPL Autloader implementation allows registering multiple autoloaders at the same time, i.e. why not use a Doctrine\Common\ClassLoader for the entities when they are namespaced and use Zend_Loader_Autoloader for the Zend stuff only? You are free to choose what combination of autoloaders you want :) On Tue, 23 Mar 2010 13:27:58 +0100, Loïc Frering <[hidden email]> wrote: > The problem is that Zend_Loader_Autoloader_Resource and, as a > consequence, Zend_Application_Module_Autoloader does not support PHP5.3 > namespaces for now. > > There is an issue related to this problem in ZF Jira: > http://framework.zend.com/issues/browse/ZF-8205 (vote for it ;) ) > > In the meantime, you should use old fashion namespaces with underscores or > extend Zend_Loader_Autoloader_Resource to make it support PHP5.3 namespaces > (see the proposed patches in Jira issue). The last solution allows to use > Doctrine convert mapping tool as it would not let generate a class named > Application_Model_User in a file named User.php from an XML or YAML mapping > file. > > Regards. > > On Tue, Mar 23, 2010 at 1:36 AM, David Muir > <[hidden email]<davidkmuir%[hidden email]> >> wrote: > >> >> They should be namespaced IMO. >> >> Also, the example given here uses namespaces: >> http://www.doctrine-project.org/blog/doctrine-2-give-me-my-constructor-back >> >> -- >> View this message in context: >> http://n4.nabble.com/Doctrine-2-0-Entities-Models-Naming-and-Autoloading-tp1678427p1678528.html >> Sent from the Zend Framework mailing list archive at Nabble.com. >> |
|
That's an other solution but, correct me if I'm wrong, it would not allow to follow ZF directories structure recommendations because an Entity Application\Model\User would be looked into Application/Model/User.php in the include_path by Doctrine ClassLoader.
The purpose of Zend_Loader_Autoloader_Resource is to let you automatically load resources (model classes, services and whatever you want) from your application directory according to a certain namespace.
On Tue, Mar 23, 2010 at 1:33 PM, Benjamin Eberlei <[hidden email]> wrote:
-- Loïc Frering [hidden email] |
|
I note that this Stackoverflow answer seems to agree with Ben Eberlei.
But I am seeing the same as Loïc Frering. I would like a class named `Application\Model\User` to be stored in the file `application/models/User.php`. The Zend resource autoloader does precisely this. The Doctrine `ClassLoader` seems to want that class to be in the file `application/Application/Model/User.php.` Anyone have an explanation or alternative approach? |
|
You should extract the ResourceLoader from ZF2 to have PHP5.3 namespaces
support: https://github.com/zendframework/zf2/blob/master/library/Zend/Loader/ResourceAutoloader.php On Thu, Jun 16, 2011 at 11:59 AM, papayasoft <[hidden email]> wrote: > I note that this > > http://stackoverflow.com/questions/4467139/zend-framework-1-11-doctrine-2-integration-autoloading-models-models-user-php/4470883#4470883 > Stackoverflow answer seems to agree with Ben Eberlei. > > But I am seeing the same as Loïc Frering. > > I would like a class named `Application\Model\User` to be stored in the > file > `application/models/User.php`. > > The Zend resource autoloader does precisely this. > > The Doctrine `ClassLoader` seems to want that class to be in the file > `application/Application/Model/User.php.` > > Anyone have an explanation or alternative approach? > > -- > View this message in context: > http://zend-framework-community.634137.n4.nabble.com/Doctrine-2-0-Entities-Models-Naming-and-Autoloading-tp1678427p3601997.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > -- > List: [hidden email] > Info: http://framework.zend.com/archives > Unsubscribe: [hidden email] > > > -- Loïc Frering [hidden email] |
|
Aaah, great idea. Thanks!
========================= David Weinraub [hidden email] Tel: +66 (81) 415-1245 Mailing Address: P.O. Box 212 Patong Post Office Kathu, Phuket 83150 THAILAND On 6/16/2011 7:04 PM, Loïc Frering wrote: > You should extract the ResourceLoader from ZF2 to have PHP5.3 namespaces > support: > https://github.com/zendframework/zf2/blob/master/library/Zend/Loader/ResourceAutoloader.php > > On Thu, Jun 16, 2011 at 11:59 AM, papayasoft <[hidden email] > <mailto:[hidden email]>> wrote: > > I note that this > http://stackoverflow.com/questions/4467139/zend-framework-1-11-doctrine-2-integration-autoloading-models-models-user-php/4470883#4470883 > Stackoverflow answer seems to agree with Ben Eberlei. > > But I am seeing the same as Loïc Frering. > > I would like a class named `Application\Model\User` to be stored in > the file > `application/models/User.php`. > > The Zend resource autoloader does precisely this. > > The Doctrine `ClassLoader` seems to want that class to be in the file > `application/Application/Model/User.php.` > > Anyone have an explanation or alternative approach? > > -- > View this message in context: > http://zend-framework-community.634137.n4.nabble.com/Doctrine-2-0-Entities-Models-Naming-and-Autoloading-tp1678427p3601997.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > -- > List: [hidden email] <mailto:[hidden email]> > Info: http://framework.zend.com/archives > Unsubscribe: [hidden email] > <mailto:[hidden email]> > > > > > > -- > Loïc Frering > [hidden email] <mailto:[hidden email]> -- List: [hidden email] Info: http://framework.zend.com/archives Unsubscribe: [hidden email] |
|
In reply to this post by papayasoft
The Symfony Universal Autoloader works nicely in this case: https://gist.github.com/937433#file_autoload.php.dist
--
Wil Moore III Best Practices for Working with Open-Source Developers http://www.faqs.org/docs/artu/ch19s02.html Why is Bottom-posting better than Top-posting: http://www.caliburn.nl/topposting.html DO NOT TOP-POST and DO trim your replies: http://linux.sgms-centre.com/misc/netiquette.php#toppost |
|
Administrator
|
-- Wil Moore III <[hidden email]> wrote
(on Friday, 17 June 2011, 11:10 AM -0700): > papayasoft wrote: > > I would like a class named `Application\Model\User` to be stored in the > > file `application/models/User.php`. > > ... > > Anyone have an explanation or alternative approach? > > > The Symfony Universal Autoloader works nicely in this case: > https://gist.github.com/937433#file_autoload.php.dist You could also use any of the autoloaders from ZF2 or the backported ones I blogged a week or two ago. :) -- Matthew Weier O'Phinney Project Lead | [hidden email] Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc -- List: [hidden email] Info: http://framework.zend.com/archives Unsubscribe: [hidden email] |
| Powered by Nabble | Edit this page |
