ZF2+没有作曲家的学说 [英] ZF2 + doctrine without composer

查看:17
本文介绍了ZF2+没有作曲家的学说的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可用的 ZF2(骨架)应用程序并且想要集成 Doctrine.

I have a working ZF2 (skeleton) application and want to integrate Doctrine.

我已经从 github 下载了 2 个模块(DoctrineModule 和 DoctrineORMModule),因为我无法使用 composer(所以请不要回答:get composer").

I have downloaded the 2 modules (DoctrineModule and DoctrineORMModule) from github as I'm unable to use composer (so please don't answer with; "get composer").

经过数小时的尝试查找问题后,我不断收到以下错误:

After hours of trying to find the problem I keep getting the following error:

致命错误:在第 54 行的学说/DoctrineModule/src/DoctrineModule/Module.php 中找不到Doc​​trineCommonAnnotationsAnnotationRegistry"类.

Fatal error: Class 'DoctrineCommonAnnotationsAnnotationRegistry' not found in doctrine/DoctrineModule/src/DoctrineModule/Module.php on line 54.

我花了数小时的时间进行搜索和调试,但找不到修复方法.请帮帮我.

I have spend hours of searching and trying to debug but I can't find a way to fix it. Please help me.

推荐答案

DoctrineORMModule 没有明确支持没有 Composer 的自动加载(因为它很乱).

DoctrineORMModule does not explicitly support autoloading without composer (since it's a mess).

DoctrineORMModule 的当前 (0.7.*) 版本开始,所需的包如下:

As of current (0.7.*) version of DoctrineORMModule, the required packages are following:

  • doctrine/common (2.3.0)
  • doctrine/dbal (2.3.2)
  • symfony/console (v2.1.7)
  • doctrine/orm (2.3.2)
  • doctrine/doctrine-module (0.7.*)
  • doctrine/doctrine-orm-module (0.7.0)

您可以做的是在 init_autoloader 中定义所有自动加载命名空间.php 在你的骨架应用程序中(解释混乱).要替换的代码是关于自动加载器工厂的部分:

What you can do is defining all the autoloading namespaces in init_autoloader.php in your skeleton application (explaining the mess). The code to replace is the part about the autoloader factory:

ZendLoaderAutoloaderFactory::factory(array(
    'ZendLoaderStandardAutoloader' => array(
        'autoregister_zf' => true,
        'namespaces' => array(
            'DoctrineCommon'   => __DIR__ . '/vendor/doctrine/common',
            'DoctrineDBAL'     => __DIR__ . '/vendor/doctrine/dbal',
            'SymfonyConsole'   => __DIR__ . '/vendor/symfony/console',
            'DoctrineModule'    => __DIR__ . '/vendor/doctrine/doctrine-module',
            'DoctrineORMModule' => __DIR__ . '/vendor/doctrine/doctrine-orm-module',
        ),
    ),
));

您必须自己配置各种 git 子模块

You will have to configure the various git submodules on your own

从模块的0.8.*版本开始,由于最近doctrine/common的拆分方式,依赖会增加不少,因此考虑寻找解决方案开始使用作曲家,否则你将来只会拖延巨大的问题.

As of version 0.8.* of the modules, the dependencies will increase quite a bit because of how doctrine/common was splitted recently, so consider finding a solution to start using composer or you will just be delaying huge problems in future.

这个解决方案现在应该有效.

This solution should work for now.

这篇关于ZF2+没有作曲家的学说的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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