php – 如何使用Propel ORM进行Zend框架

我想将Propel与Zend框架相结合.过去,我看到了学说的整合,但是 this post表示,似乎推动的方式有所不同.

Propel has two things going for it already: the first is that Propel includes its own autoloader,meaning that I didn’t have to try and force Propel into Zend Framework’s file system structure. The second is that Propel is designed to let you put it’s files anywhere you want with ease,so long as you update your include path properly. This made the process significantly easier than I had thought it would be.

但是,这篇文章没有详细介绍如何完成.我猜想我必须修改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一段时间,它花了我几个星期工作所有的扭结:-)

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...