zend框架中的命名空间声明错误

时间:2015-02-16 08:29:58

标签: php zend-framework

我创建了一个名为Album的新模块。我添加了以下代码:
<AppName>/module/Album/Module.php

 <?php

namespace Album;

use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;

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';
 }
}

<AppName>/module/Album/config/module.config.php

<?php

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

 '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',
         ),
     ),
 );

然后我刷新了我的本地服务器并得到了这个错误:

Fatal error: Namespace declaration statement has to be the very first statement in the script in /var/www/html/trialone/module/Album/Module.php on line 3

我该如何解决?

0 个答案:

没有答案