Symfony 和 Doctrine:项目结构约定

发布于 2024-10-03 18:59:05 字数 284 浏览 0 评论 0原文

我使用 symfony 的 ProjectConfiguration.class.php 来配置原则的连接:

public function configureDoctrineConnectionCertby(Doctrine_Connection $conn)
{
   $conn->setListener(new MyListner());
}

Where should I Define MyListner class inside a symfony project?

I use symfony's ProjectConfiguration.class.php for configuring doctrine's connection:

public function configureDoctrineConnectionCertby(Doctrine_Connection $conn)
{
   $conn->setListener(new MyListner());
}

Where should I define MyListner class within a symfony project?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

北座城市 2024-10-10 18:59:05

您应该为所有 Doctrine 文件创建一个 lib/Doctrine (或 lib/doctrine/Doctrine - 这是 Symfony 在 sfDoctrineGuardPlugin 内部所做的)文件夹。由于监听器是 Doctrine 文件而不是 Symfony 文件,因此您应该遵循它们的 Doctrine 命名约定。在这种情况下,MyListener 将进入:

/lib/Doctrine/Record/Listener/MyListener.php

这是执行此操作的“正确”方法。如果您只是将文件放入 /lib/lib/Doctrine 中,那么当然可以工作。

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.

眼眸里的那抹悲凉 2024-10-10 18:59:05

如果您希望侦听器在项目级别可用,请将其放在 /project/lib/ 文件夹中。如果您只想在模块级别使用它,请将其放在 /project/apps/module/lib/ 文件夹中。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文