0

我无法将 ZfcUser / ZfcBase 模块安装到 ZF2 骨架应用程序中。(Ubuntu 12.10 服务器、Apache、PHP5.4.6)

1)下载并解压ZF2骨架应用程序

2) 下载 ZF2 库并解压到 /vendor/ZF2

此时,骨架应用程序工作正常。

3) 下载 ZfcBase 和 ZfcUser 并将其解压缩到 /vendor/ 中(例如,我有 /vendor/ZfcXxxx/Module.php)

4) 编辑 config/application.config.php 以包含两个新模块

<?php
return array(
    // This should be an array of module namespaces used in the application.
    'modules' => array(
        'Application',
        'ZfcBase',
        'ZfcUser',
    ),

我现在得到

Fatal error:  Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (ZfcBase) could not be initialized.' in /home/ubuntu/zf2-skel/vendor/ZF2/library/Zend/ModuleManager/ModuleManager.php:144
Stack trace:
#0 /home/ubuntu/zf2-skel/vendor/ZF2/library/Zend/ModuleManager/ModuleManager.php(85): Zend\ModuleManager\ModuleManager->loadModule('ZfcBase')
#1 [internal function]: Zend\ModuleManager\ModuleManager->onLoadModules(Object(Zend\ModuleManager\ModuleEvent))
#2 /home/ubuntu/zf2-skel/vendor/ZF2/library/Zend/EventManager/EventManager.php(464): call_user_func(Array, Object(Zend\ModuleManager\ModuleEvent))
#3 /home/ubuntu/zf2-skel/vendor/ZF2/library/Zend/EventManager/EventManager.php(208): Zend\EventManager\EventManager->triggerListeners('loadModules', Object(Zend\ModuleManager\ModuleEvent), NULL)
#4 /home/ubuntu/zf2-skel/vendor/ZF2/library/Zend/ModuleManager/ModuleManager.php(104): Zend\EventManager\EventManager->trigger('loadModules', Object(Zend\ModuleManager\ModuleManager), Object(Zend\ModuleMan in /home/ubuntu/zf2-skel/vendor/ZF2/library/Zend/ModuleManager/ModuleManager.php on line 144

大概我错过了一些自动加载配置......

4

2 回答 2

0

使用 composer.phar 非常有用。

php composer.phar self-update
php composer.phar install

无论如何检查您的“autoload_classmap.php”并验证 ZfcBase 的添加。

于 2013-03-31T21:50:44.837 回答
0

我没有使用作曲家(出于各种原因)。这个缺少的配置告诉应用程序加载模块的 autoload_classmap.php 文件就是这样。

Zend\Loader\AutoloaderFactory::factory([
    'Zend\Loader\StandardAutoloader' => [
        'autoregister_zf' => true
    ],
    'Zend\Loader\ClassMapAutoloader' => [
        __DIR__ . '/../vendor/ZfcBase/autoload_classmap.php',
        __DIR__ . '/../vendor/ZfcUser/autoload_classmap.php',
    ],
]);
于 2013-03-31T22:45:25.797 回答