模块(专辑)无法初始化zf2教程

Mat*_*ter 3 php zend-framework2

我正在通过zend框架2教程应用程序.我已经设置了我的相册模块目录,如下所示:

在此输入图像描述

我启动MAMP服务器时遇到错误, Fatal error: Uncaught exception 'Zend\ModuleManager\Exception\RuntimeException' with message 'Module (Album) could not be initialized.'

如果我Album从以下代码中注释掉该模块(in /config/application.config.php):

'modules' => array(
    'Application',
    'Album',
),
Run Code Online (Sandbox Code Playgroud)

我到了骨架应用程序主页.这是我的/module/Album/Module.php代码:

namespace Album;

use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
use Album\Model\Album;
use Album\Model\AlbumTable;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;

class Module implements AutoloaderProviderInterface, ConfigProviderInterface {

public function getAutoloaderConfig() {
    return array(
        ’Zend\Loader\ClassMapAutoloader’ => array(
            __DIR__ . ’/autoload_classmap.php’,
        ),
        ’Zend\Loader\StandardAutoloader’ => array( ’namespaces’ => array(
            __NAMESPACE__ => __DIR__ . ’/src/’ . __NAMESPACE__,
            ),
        ), 
    );
}

public function getConfig() {
    return include __DIR__ . ’/config/module.config.php’; 
}

public function getServiceConfig() {
    return array(
        ’factories’ => array(
            ’Album\Model\AlbumTable’ => function($sm) { 
                $tableGateway = $sm->get(’AlbumTableGateway’); 
                $table = new AlbumTable($tableGateway);
                return $table;
            },
            ’AlbumTableGateway’ => function ($sm) {
                $dbAdapter = $sm->get(’Zend\Db\Adapter\Adapter’);
                $resultSetPrototype = new ResultSet(); $resultSetPrototype->setArrayObjectPrototype(new Album());
                return new TableGateway(’album’, $dbAdapter, null, $resultSetPrototype);
            }, 
        ),
    ); 
}
}
Run Code Online (Sandbox Code Playgroud)

这是我的module.config.php代码/module/Album/config/:

return array(
’controllers’ => array(
    ’invokables’ => array(
        ’Album\Controller\Album’ => ’Album\Controller\AlbumController’,
    ),
),

’view_manager’ => array( 
    ’template_path_stack’ => array(
        ’album’ => __DIR__ . ’/../view’,
    ),
),

'router' => array(
    'routes' => array(
        'album' => array(
            'type' => 'segment',
            'options' => array(
                'route' => '/album[/][:action][/:id]',
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'id' => '[0-9]+',
                ),
                'defaults' => array(
                    'controller' => 'Album\Controller\Album',
                    'action' => 'index',
                ),
            ),
        ),
    ),
),'
);
Run Code Online (Sandbox Code Playgroud)

我已经阅读了一些遇到过类似情况的人,但他们的问题是由于拼写错误/错误命名的课程造成的.我没有看到我的代码有任何问题(甚至直接从教程复制/粘贴).

有人可以给我一些建议吗?

谢谢

nul*_*ilt 10

我有同样的问题,解决方案是启动每个.php文件.<?php 这在教程中不明确(如果你只是从那里复制代码),这就是我得到相同的异常的原因.