问题描述
我想将Propel
与Zend framework
集成在一起.我过去曾经看到过教义的整合,但是这篇文章说,推进似乎有所不同.
I'd like to integrate Propel
with Zend framework
. I've seen the integration of doctrine in the past but this post says it seems propel is done a bit differently.
但是该帖子并未详细介绍如何完成.我猜我必须修改Zend
Bootstrap.php
和application.ini
(我使用的是最新的Zend 1.10.8
),但是我发现很难找到有关Zend
最新版本的帖子使用最新版本的Propel
.
But the post doesn't go into full details on how to finish it. I'm guessing I have to modify the Zend
Bootstrap.php
and application.ini
(I'm using the latest Zend 1.10.8
), but I'm finding it difficult to find a post on the latest version of Zend
with the latest version of Propel
.
任何人都可以评论如何以最流畅的方式进行此操作吗?
Anyone can comment how to do this in the smoothest way possible?
另一个问题:Propel
是否具有命令行界面,或者如果我正在使用Zend
的命令行界面,是否不需要命令行界面来推进?
another question: does Propel
has a command line interface or do I not need a command line interface for propel if I'm using the command line interface of Zend
?
推荐答案
我没有在Symfony之外使用Propel,但是从我对Propel的了解中,我认为类似以下内容的东西对运行时有效:
I havent use Propel outside of Symfony but from what i know of Propel but i would think something like the following would work for the runtime stuff:
在您的引导程序中
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)
In your application.xml (adapt to ini if thats what you prefer)
<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 build,看看编译后的php数组.然后将其映射到xml或ini并将其直接嵌入到您的应用程序配置文件中.然后修改您的initPropel
以使其处理如下:
Of course this isnt really full integration as far as im concerned... but it should be enough to get you up and running without a lot of hassle. If its worth the investment to you on this project i would go ahead and make an Application Resource. Run a propel build and take a look at the compiled php array. Then map that to xml or ini and embed it directly in your application config file. Then modify your initPropel
to handle it like:
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
.
If you wanted you could even not directly load the array as parsed from the configuration file but instead create a PropelConfiguration
object and programtically set all your parameters, then pass that to setConfiguration
.
对于构建工具,香港专业教育学院发现与Zend_Tool集成非常麻烦,因此我倾向于依靠phing
或自定义的shell脚本来完成所有工作.除非您计划在许多项目上使用Propel,否则可能不会花费时间来实现此级别的集成.我前一阵子用Doctrine 1.x做到了,花了我几个星期的时间才解决了所有问题:-)
As for the build tools, ive found integrating with Zend_Tool to be an ordeal so i tend to rely on phing
or custom shell scripts for all that. Unless you plan on using Propel on a lot of projects its probably not with the time to implement this level of integration. I did it with Doctrine 1.x a while back and it took me a couple weeks to work all the kinks out :-)
这篇关于如何使用Propel ORM修改Zend框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!