1

当我尝试启动相册应用程序时,会出现一条错误消息:

致命错误:在第 170 行的 C:\xampp\htdocs\ZendSkeletonApplication\vendor\zendframework\zendframework\library\Zend\ServiceManager\AbstractPluginManager.php 中找不到类 'Album\Controller\AlbumController'

这是我的 module.config.php 文件代码

<?php
return array(
    'controllers' => array(
        'invokables' => array(
            'Album\Controller\Album' => 'Album\Controller\AlbumController',
        ),
    ),

    // Added to make router
    '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',
                    ),
                ),
            ),
        ),
    ),

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

这是 AlbumController.php 文件代码:

<?php

namespace Album\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;

class AlbumController extends AbstractActionController {

    protected $albumTable;

    public function indexAction() {
        return new ViewModel(array(
            'album' => $this->getAlbumTable()->fetchAll(),
        ));
    }

    public function addAction() {

    }

    public function editAction() {

    }

    public function deleteAction() {

    }

    public function getAlbumTable () {
        if (!$this->albumTable) {
            $sm = $this->getServiceLocator();
            $this->albumTable = $sm->get('Album\Model\AlbumTable');
        }
        return $this->albumTable;
    }

}
4

1 回答 1

1

我看到你才刚刚开始,所以我会参考Martin Shwalbe的这段代码,看看你是否有任何拼写错误。如果一切看起来都不错,那么您访问它的方式可能有问题。

https://github.com/Hounddog/Album

希望这可以帮助...

于 2013-11-07T12:34:46.653 回答