Symfony and Doctrine: project structure convention
I use symfony's ProjectConfiguration.class.php for configuring doctrine's connection:
public function configureDoctrineConnectionCertby(Doctrine_Connection $conn)
{
$conn-&开发者_运维问答gt;setListener(new MyListner());
}
Where should I define MyListner class within a symfony project?
You should make a lib/Doctrine
(or lib/doctrine/Doctrine
- this is what Symfony does inside of sfDoctrineGuardPlugin) folder for all Doctrine files. Since Listeners are Doctrine files not Symfony files, you should be following Doctrine naming conventions for them. In this case, MyListener would go in:
/lib/Doctrine/Record/Listener/MyListener.php
This is the "proper" way to do this. It would of course work if you simply threw the files in /lib
or /lib/Doctrine
.
If you want your listener to be available at the project level, put it in the /project/lib/ folder. If you just want it to be available at the module level, put it in the /project/apps/module/lib/ folder.
精彩评论