<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:我在哪里放置我的模型/实体和代理类

      Integrating ZF/Doctrine2: Where do i put my Models/Entities amp; Proxy classes(集成 ZF/Doctrine2:我在哪里放置我的模型/实体和代理类)
        <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:我在哪里放置我的模型/实体和代理类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                    <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>
                        • <small id='QtJqz'></small><noframes id='QtJqz'>

                            <tbody id='QtJqz'></tbody>
                          <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>