php – 如何使用Propel ORM进行Zend框架
我想将Propel与Zend框架相结合.过去,我看到了学说的整合,但是
this post表示,似乎推动的方式有所不同.
但是,这篇文章没有详细介绍如何完成.我猜想我必须修改Zend Bootstrap.php和application.ini(我使用的是最新的Zend 1.10.8),但是我发现很难在最新的Zend版本上找到最新版本的Zend Propel版本. 任何人都可以以最平滑的方式评论如何做到这一点? 另一个问题:Propel是否有命令行界面,如果我使用Zend的命令行界面,我不需要propel的命令行界面?
我没有使用Propel在Symfony之外,但从我所知道的Propel,但我会认为像以下这样的事情将适用于运行时的东西:
在你的引导 public function initPropel() { require_once 'Propel.php'; Propel::init($this->getOptions('propelConfig')); // so we can get the connection from the registry easily return Propel::getConnection(); } 在你的application.xml(适应ini,如果你喜欢) <applicationConfiguration xmlns:zf="http://framework.zend.com/xml/zend-config-xml/1.0/"> <production> <!-- other stuff --> <includePaths> <propelRuntime><zf:const zf:name="APPLICATION_PATH" />/../library/propel/runtime</propelRuntime> </includePaths> <propelConfig><zf:const zf:name="APPLICATION_PATH" />/configs/propel-runtime.php</propelConfig> <!-- other stuff --> </production> </applicationConfiguration> 当然这并不是真正的完全整合,只要我关心…但它应该足以让你运行没有很多麻烦.如果它值得投资给你这个项目,我会继续做一个应用资源.运行propel构建并查看编译的php数组.然后将其映射到xml或ini,并将其直接嵌入到应用程序配置文件中.然后修改你的initPropel来处理它: public function initPropel() { require_once 'Propel.php'; Propel::setConfiguration($this->getOptions('propelConfig')); Propel::initialize(); // so we can get the connection from the registry easily return Propel::getConnection(); } 如果您希望您甚至可以不直接从配置文件中加载数组,而是创建一个PropelConfiguration对象并以编程方式设置所有参数,然后将其传递给setConfiguration. 对于构建工具,ive发现与Zend_Tool集成是一种折磨,所以我倾向于依赖于所有这些的phing或custom shell脚本.除非您计划在很多项目上使用Propel,否则可能并没有实现这一级别的集成.我做了一个Doctrine 1.x一段时间,它花了我几个星期工作所有的扭结:-) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |