<bdo id='cJNAA'></bdo><ul id='cJNAA'></ul>

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

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

    1. <tfoot id='cJNAA'></tfoot><legend id='cJNAA'><style id='cJNAA'><dir id='cJNAA'><q id='cJNAA'></q></dir></style></legend>

      1. Zend 框架 2 + Doctrine 2

        时间:2023-10-02
        <i id='DKEH7'><tr id='DKEH7'><dt id='DKEH7'><q id='DKEH7'><span id='DKEH7'><b id='DKEH7'><form id='DKEH7'><ins id='DKEH7'></ins><ul id='DKEH7'></ul><sub id='DKEH7'></sub></form><legend id='DKEH7'></legend><bdo id='DKEH7'><pre id='DKEH7'><center id='DKEH7'></center></pre></bdo></b><th id='DKEH7'></th></span></q></dt></tr></i><div id='DKEH7'><tfoot id='DKEH7'></tfoot><dl id='DKEH7'><fieldset id='DKEH7'></fieldset></dl></div>

        1. <tfoot id='DKEH7'></tfoot>
            <tbody id='DKEH7'></tbody>

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

              <legend id='DKEH7'><style id='DKEH7'><dir id='DKEH7'><q id='DKEH7'></q></dir></style></legend>

              • <bdo id='DKEH7'></bdo><ul id='DKEH7'></ul>
                • 本文介绍了Zend 框架 2 + Doctrine 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想开始使用 Zend Framework 进行开发,并且我想使用 zf2.由于我使用 Doctrine 2,您能否建议一些教程来帮助我将其集成到 zf2 中?谢谢!

                  I would like to start developing with Zend Framework and I would like to use zf2. Since I use Doctrine 2, can you suggest some tutorials to help me to integrate it in zf2? Thanks!

                  推荐答案

                  上次检查:ZF2.2.*, DoctrineORMModule 0.7.

                  您可能希望通过 composer 加载 DoctrineORMModule:

                  You may want to load DoctrineORMModule via composer:

                  • doctrine/doctrine-orm-module 添加到您的 composer.json 的 require(格式问题列表后的示例代码)
                  • 运行 php composer.phar install
                  • 创建目录 ./data/DoctrineORMModule/Proxy 并确保您的应用程序具有写入权限
                  • 配置原则通过你的应用程序/config/autoload给模块项目特定的设置(数据库等)
                  • 在你的模块中配置学说的实体映射config.php
                  • 向您的项目添加实体
                  • DoctrineORMModuleDoctrineModule 添加到您的 config/application.config.php
                  • 运行 cli 工具来生成你的表 ./vendor/bin/doctrine-module orm:schema-tool:create
                  • add doctrine/doctrine-orm-module to your composer.json's require (example code after list bcs of formatting problems)
                  • run php composer.phar install
                  • create the directory ./data/DoctrineORMModule/Proxy and ensure write access for your application
                  • configure doctrine via your applications /config/autoload to give the module the project-specific settings (database etc)
                  • configure doctrine's entity mapping in your modules config.php
                  • add an entity to your project
                  • add DoctrineORMModule and DoctrineModule to your config/application.config.php
                  • run the cli tool to generate your tables ./vendor/bin/doctrine-module orm:schema-tool:create

                  我强烈建议您不要使用 Composer,因为这是安装依赖项和设置自动加载器的简单方法.默认情况下,ZF2 也通过 Composer 发布.

                  I strongly discourage you from not using composer, as it is an easy way to install dependencies and have the autoloaders all set up. Also ZF2 ships via composer by default.

                  {  
                      "require" : {  
                          "php": ">=5.3.3",  
                          "zendframework/zendframework": "2.*"                
                          "doctrine/doctrine-orm-module": "0.*"                
                      }  
                  }  
                  

                  实体设置

                  <?php
                  return array(
                      'doctrine' => array(
                          'driver' => array(
                              // defines an annotation driver with two paths, and names it `my_annotation_driver`
                              'my_annotation_driver' => array(
                                  'class' => 'DoctrineORMMappingDriverAnnotationDriver',
                                  'cache' => 'array',
                                  'paths' => array(
                                      'path/to/my/entities',
                                      'another/path'
                                  ),
                              ),
                  
                              // default metadata driver, aggregates all other drivers into a single one.
                              // Override `orm_default` only if you know what you're doing
                              'orm_default' => array(
                                  'drivers' => array(
                                      // register `my_annotation_driver` for any entity under namespace `MyNamespace`
                                      'MyNamespace' => 'my_annotation_driver'
                                  )
                              )
                          )
                      )
                  );
                  

                  需要注意的问题:通往实体的路径应该是完全合格的.最好从 __DIR__ 开始,否则事情会崩溃(每个新项目我都想知道为什么命令行工具在我发现这个错误之前不起作用......;)

                  A gotcha to be aware of: The paths to your entites should be fully qualified. Best start with __DIR__, else things will break (Every new project I wonder why the command line tool doesn't work until I find this error ... ;)

                  <?php
                  return array(
                      'doctrine' => array(
                          'connection' => array(
                              // default connection name
                              'orm_default' => array(
                                  'driverClass' => 'DoctrineDBALDriverPDOMySqlDriver',
                                  'params' => array(
                                      'host'     => 'localhost',
                                      'port'     => '3306',
                                      'user'     => 'username',
                                      'password' => 'password',
                                      'dbname'   => 'database',
                                  )
                              )
                          )
                      ),
                  );
                  

                  所有代码示例都是官方学说模块自述文件的一部分

                  Marco Pivetta 做了一个关于学说模块使用的精彩演讲,我向所有使用此模块的人推荐.

                  Marco Pivetta made a wonderful presentation about doctrine-module usage, which I recommend to everybody using this module.

                  Jason Grimes 写了一个教程 在 phpdeveloper.org 上有特色,这应该有助于安装学说,然后才有官方模块.

                  Jason Grimes wrote a tutorial featured on phpdeveloper.org which should help installing doctrine, before there was an official module.

                  这篇关于Zend 框架 2 + Doctrine 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Zend Framework 1 与 Zend Framework 2 性能对比 下一篇:Zend Framework:控制器对象中的 init() 和 preDispatch()

                  相关文章

                  最新文章

                    <bdo id='k1BHW'></bdo><ul id='k1BHW'></ul>

                • <i id='k1BHW'><tr id='k1BHW'><dt id='k1BHW'><q id='k1BHW'><span id='k1BHW'><b id='k1BHW'><form id='k1BHW'><ins id='k1BHW'></ins><ul id='k1BHW'></ul><sub id='k1BHW'></sub></form><legend id='k1BHW'></legend><bdo id='k1BHW'><pre id='k1BHW'><center id='k1BHW'></center></pre></bdo></b><th id='k1BHW'></th></span></q></dt></tr></i><div id='k1BHW'><tfoot id='k1BHW'></tfoot><dl id='k1BHW'><fieldset id='k1BHW'></fieldset></dl></div>
                  1. <small id='k1BHW'></small><noframes id='k1BHW'>

                      <legend id='k1BHW'><style id='k1BHW'><dir id='k1BHW'><q id='k1BHW'></q></dir></style></legend>
                      <tfoot id='k1BHW'></tfoot>