<i id='w41bl'><tr id='w41bl'><dt id='w41bl'><q id='w41bl'><span id='w41bl'><b id='w41bl'><form id='w41bl'><ins id='w41bl'></ins><ul id='w41bl'></ul><sub id='w41bl'></sub></form><legend id='w41bl'></legend><bdo id='w41bl'><pre id='w41bl'><center id='w41bl'></center></pre></bdo></b><th id='w41bl'></th></span></q></dt></tr></i><div id='w41bl'><tfoot id='w41bl'></tfoot><dl id='w41bl'><fieldset id='w41bl'></fieldset></dl></div>

        <bdo id='w41bl'></bdo><ul id='w41bl'></ul>
      <tfoot id='w41bl'></tfoot><legend id='w41bl'><style id='w41bl'><dir id='w41bl'><q id='w41bl'></q></dir></style></legend>

      <small id='w41bl'></small><noframes id='w41bl'>

    1. 集成 ZF/Doctrine2:我在哪里放置我的模型/实体和代理类

      时间:2024-08-09
        <tbody id='FjNVZ'></tbody>
        <bdo id='FjNVZ'></bdo><ul id='FjNVZ'></ul>

            <legend id='FjNVZ'><style id='FjNVZ'><dir id='FjNVZ'><q id='FjNVZ'></q></dir></style></legend>
            <i id='FjNVZ'><tr id='FjNVZ'><dt id='FjNVZ'><q id='FjNVZ'><span id='FjNVZ'><b id='FjNVZ'><form id='FjNVZ'><ins id='FjNVZ'></ins><ul id='FjNVZ'></ul><sub id='FjNVZ'></sub></form><legend id='FjNVZ'></legend><bdo id='FjNVZ'><pre id='FjNVZ'><center id='FjNVZ'></center></pre></bdo></b><th id='FjNVZ'></th></span></q></dt></tr></i><div id='FjNVZ'><tfoot id='FjNVZ'></tfoot><dl id='FjNVZ'><fieldset id='FjNVZ'></fieldset></dl></div>

              1. <tfoot id='FjNVZ'></tfoot>
              2. <small id='FjNVZ'></small><noframes id='FjNVZ'>

                本文介绍了集成 ZF/Doctrine2:我在哪里放置我的模型/实体和代理类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                如果我确实将 Zend Framework 1.10 与 Doctrine 2 集成在一起,我将我的 Doctrine 模型/实体和代理放在哪里?我想到了 /application/library 目录.如果我确实放入 /library 目录,它会干扰 ZF 从那里自动加载类,因为那里的类将使用 PHP 5.3 命名空间与 PEAR 样式命名空间.

                if i do integrate Zend Framework 1.10 with Doctrine 2 where do i put my Doctrine Models/Entities and Proxies? i thought of the /application or the /library directories. if i do put in the /library directory tho, will it interfere with ZF autoloading classes from there since the classes there will be using PHP 5.3 namespaces vs PEAR style namespaces.

                推荐答案

                我正在开发一个集成 Doctrine 2 和 ZF1.10 的应用程序.你根本不需要使用 Doctrine 自动加载器.

                I'm working on an application that integrates Doctrine 2 with ZF1.10 also.You don't need to use the Doctrine auto loader at all.

                1) 在您的 application.ini 文件中添加以下行(假设您在库文件夹中安装了 Doctrine(与 Zend 文件夹相同):

                1) In your application.ini file add the following line (assuming you have Doctrine installed in your library folder (same as the Zend folder):

                autoloadernamespaces.doctrine = "Doctrine"
                

                2) 创建一个学说或实体管理器资源.在您的 ini 文件中:

                2) Create a doctrine or entitymanager resource. In your ini file:

                resources.entitymanager.db.driver = "pdo_mysql"
                resources.entitymanager.db.user = "user"
                resources.entitymanager.db.dbname = "db"
                resources.entitymanager.db.host = "localhost"
                resources.entitymanager.db.password = "pass"
                resources.entitymanager.query.cache = "DoctrineCommonCacheApcCache"
                resources.entitymanager.metadata.cache = "DoctrineCommonCacheApcCache"
                resources.entitymanager.metadata.driver = "DoctrineORMMappingDriverAnnotationDriver"
                resources.entitymanager.metadata.proxyDir = APPLICATION_PATH "/../data/proxies"
                resources.entitymanager.metadata.entityDir[] = APPLICATION_PATH "/models/entity"
                

                3) 接下来,您需要引导它.我在资源文件夹中添加了一个资源类.确保映射到 ini 文件中的文件夹:

                3) Next, you will need to bootstrap it. I added a resource class in my resources folder. Make sure you map to the folder in your ini file:

                pluginPaths.Application_Resource_ = APPLICATION_PATH "/resources"
                

                那么你的资源类...

                class Application_Resource_EntityManager 
                extends Zend_Application_Resource_ResourceAbstract
                {
                    /**
                     * @var DoctrineORMEntityManager
                     */
                    protected $_em;
                
                    public function init()
                    {
                        $this->_em = $this->getEntityManager();
                        return $this->_em;
                    }
                
                    public function getEntityManager()
                    {
                        $options = $this->getOptions(); 
                        $config = new DoctrineORMConfiguration();
                        $config->setProxyDir($options['metadata']['proxyDir']);
                        $config->setProxyNamespace('Proxy');
                        $config->setAutoGenerateProxyClasses((APPLICATION_ENV == 'development'));
                        $driverImpl = $config->newDefaultAnnotationDriver($options['metadata']['entityDir']);
                        $config->setMetadataDriverImpl($driverImpl);
                        $cache = new DoctrineCommonCacheArrayCache();
                        $config->setMetadataCacheImpl($cache);
                        $config->setQueryCacheImpl($cache);
                
                        $evm = new DoctrineCommonEventManager();
                        $em = DoctrineORMEntityManager::create($options['db'],$config,$evm);
                
                        return $em;
                    }
                }
                

                现在您的应用程序可以使用原则 2 实体管理器.在您的控制器中,您可以像这样抓取它:

                The doctrine 2 entity manager is now available to your application. In your controller you can grab it like so:

                $bootstrap = $this->getInvokeArg('bootstrap');
                $em = $bootstrap->getResource('entitymanager');
                

                我相信这会对某人有所帮助:)

                I am sure this will help somebody :)

                这篇关于集成 ZF/Doctrine2:我在哪里放置我的模型/实体和代理类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:将自定义 DQL 函数与 Doctrine 和 Symfony2 一起使用时出错 下一篇:Symfony2:如何获取标记为“EDIT"的一种类型的所有实体ACL 权限?

                相关文章

                  <tfoot id='QtJqz'></tfoot>
                    <bdo id='QtJqz'></bdo><ul id='QtJqz'></ul>

                    <legend id='QtJqz'><style id='QtJqz'><dir id='QtJqz'><q id='QtJqz'></q></dir></style></legend>
                  1. <small id='QtJqz'></small><noframes id='QtJqz'>

                    <i id='QtJqz'><tr id='QtJqz'><dt id='QtJqz'><q id='QtJqz'><span id='QtJqz'><b id='QtJqz'><form id='QtJqz'><ins id='QtJqz'></ins><ul id='QtJqz'></ul><sub id='QtJqz'></sub></form><legend id='QtJqz'></legend><bdo id='QtJqz'><pre id='QtJqz'><center id='QtJqz'></center></pre></bdo></b><th id='QtJqz'></th></span></q></dt></tr></i><div id='QtJqz'><tfoot id='QtJqz'></tfoot><dl id='QtJqz'><fieldset id='QtJqz'></fieldset></dl></div>