PHP MVC 最佳实践与原则 2
我想使用 Doctrine 作为 ORM 在 PHP 中进行开发,假设 Doctrine 充当模型。我知道有一个像 Symfony 这样的 Web 框架默认使用 Doctrine,但我需要知道是否有一个好的解决方案可以在 MVC 中部署 PHP + Doctrine。
I would like to develop in PHP using Doctrine as the ORM, assuming that Doctrine act as the Model. I know that there's a web framework such as Symfony which uses Doctrine as default, but I need to know if there's a good solution to deploy PHP + Doctrine in MVC.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Zend Framework 是一个很棒的 PHP 框架,并且有许多用于集成 Doctrine 和 ZF 的好资源。
特别是,对于 Doctrine 1,请查看 Zendcast:
http: //www.zendcasts.com/introducing-doctrine-1-2-integration/2009/11/
对于 Doctrine 2,请查看以下位置的应用程序资源和引导代码:
https://github.com/guilhermeblanco/ZendFramework1-Doctrine2
或
https://github.com/marsbomber/zf1-doctrine2
Zend Framework is a great PHP framework and there are many good resources for integrating Doctrine and ZF.
In particular, for Doctrine 1, check out the Zendcast:
http://www.zendcasts.com/introducing-doctrine-1-2-integration/2009/11/
For Doctrine 2, check out the the application resource and bootstrap code in:
https://github.com/guilhermeblanco/ZendFramework1-Doctrine2
or
https://github.com/marsbomber/zf1-doctrine2
我认为您需要在 MVC 解决方案中找到适当的位置来放置 Doctrine 初始化代码。我们框架的示例: https://github.com/ ysubach/mvcskel/blob/master/lib/MvcSkel/Filter/DoctrineInit.php
完成后,您可以轻松地从控制器类调用模型方法。
I think you need to find appropriate place in your MVC solution to put Doctrine initialization code. Example from our framework: https://github.com/ysubach/mvcskel/blob/master/lib/MvcSkel/Filter/DoctrineInit.php
Once it's done you can easily call model methods from controller classes.
这是我使用的 github 骨架项目,它在引导程序中使用 Zend Franework 1.11.2 进行了原则 2 初始化,干净整洁,使用实体模型和实体模型。业务逻辑的模型存储库。单元测试和ant 构建脚本也适合 TDD 开发人员。
https://github .com/eddiejaoude/Zend-Framework--Doctrine-ORM--PHPUnit--Ant--Jenkins-CI--TDD-
ZF 是一个很棒的 php 框架 &将它与教义相结合,使其成为一个非常强大的组合。
享受
Here is the github skeleton project I used, it did the doctrine 2 initialisation with Zend Franework 1.11.2 in the bootstrap, nice and clean, using model for entities & model repository for business logic. Unit tests & ant build script too for you TDD developers out there.
https://github.com/eddiejaoude/Zend-Framework--Doctrine-ORM--PHPUnit--Ant--Jenkins-CI--TDD-
ZF is an awesome php framework & combining it with doctrine makes it a very powerful combination.
Enjoy