Zend Skeleton应用相册教程404

Zend Skeleton Application album tutorial 404

据我所知,我已经完全按照 Zend skeleton application tutorial 进行了操作(实际上我已经检查了两次,结果相同)但是当我尝试访问 zf2-tutorial.localhost/album 时,我得到了以下错误:

A 404 error occurred
Page not found.
The requested URL could not be matched by routing.

No Exception available
© 2005 - 2015 by Zend Technologies Ltd. All rights reserved.

转到 zf2-tutorial.localhost 会显示 Zend 欢迎页面,并且 404 包含在 Zend 样式中,所以至少看起来有些东西在工作。

我已经尝试过针对类似问题提供的解决方案 and here 但无济于事,如有任何想法,我们将不胜感激。谢谢。

编辑:我在 XAMPP 上本地使用 运行 教程。

为了解决与配置服务器相关的问题以使用 zend,我建议您安装 WAMP 服务器。然后通过将 zend 文件上传到子目录,您将能够开始使用 zend。

也尝试使用下面提供的 .htaccess

RewriteEngine On
# The following rule tells Apache that if the requested filename
# exists, simply serve it.
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
# The following rewrites all other queries to index.php. The 
# condition ensures that if you are using Apache aliases to do
# mass virtual hosting, the base path will be prepended to 
# allow proper resolution of the index.php file; it will work
# in non-aliased environments as well, providing a safe, one-size 
# fits all solution.
RewriteCond %{REQUEST_URI}:: ^(/.+)(.+)::$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteRule ^(.*)$ %{ENV:BASE}index.php [NC,L]

似乎这个错误与.htaccess 无关,它的配置问题。请确保您已在 Album\config\module.config.php 文件中定义了所需的死记硬背:

http://framework.zend.com/manual/current/en/user-guide/routing-and-controllers.html#routing-and-controllers

结果是 module.config.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',
                     ),
                 ),
             ),
         ),
     ), 
);