开发者

Symfony and Doctrine: project structure convention

开发者 https://www.devze.com 2023-01-26 06:19 出处:网络
I use symfony\'s ProjectConfiguration.class.php for configuring doctrine\'s connection: public function configureDoctrineConnectionCertby(Doctrine_Connection $conn)

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消