如何使用Propel ORM修改Zend框架 [英] How to Zend Framework with Propel ORM

查看:82
本文介绍了如何使用Propel ORM修改Zend框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将PropelZend 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.

Propel已经完成了两件事:首先是Propel包括自己的自动加载器,这意味着我不必尝试强制Propel进入Zend Framework的文件系统结构.第二个原因是Propel旨在让您轻松地将其文件放置在所需的任何位置,只要您正确更新include path即可.这使该过程比我原来想象的要容易得多.

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.phpapplication.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框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆