简体   繁体   English

Zend FrameWork 2 Album教程错误:发生404错误找不到页面

[英]Zend FrameWork 2 Album tutorial Error : A 404 error occurred Page not found

I am following the below tutorial to implement the [skeleton application][1]. 我正在遵循以下教程来实现[骨架应用程序] [1]。

I have copy-pasted all the code provided in the tutorial, but I am getting the below error: 我已经复制粘贴了教程中提供的所有代码,但是出现以下错误:

A 404 error occurred 发生404错误

Page not found. 网页未找到。

The requested URL could not be matched by routing. 路由无法匹配请求的URL。

No Exception available 没有例外

I have cross checked all the similar issues in StackOverflow, but none of them were able to solve my issue. 我已经交叉检查了StackOverflow中所有类似的问题,但是没有一个能够解决我的问题。

Can some one help me in this? 有人可以帮我吗?

Please find the below code.: 请找到以下代码:

C:\\wamp64\\www\\zend\\module\\Album\\Module.php

<?php

namespace Album;

use Album\Model\AlbumTable;

class Module
{
    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 getServiceConfig()
    {
        return array(
            'factories' => array(
                'Album\Model\AlbumTable' =>  function($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $table = new AlbumTable($dbAdapter);
                    return $table;
                },
            ),
        );
    }    

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

C:\\wamp64\\www\\zend\\module\\Album\\config\\module.config.php C:\\ wamp64 \\ www \\ zend \\ 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',
        ),
    ),
);

Is there a way in zend to do a debug on where the issue is occurring? zend中是否可以对发生问题的地方进行调试?

.htaccess file includes the below code .htaccess文件包含以下代码

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

vhost is as below 虚拟主机如下

<VirtualHost *:80>
    ServerName zend
    DocumentRoot c:/wamp64/www/zend/public
    <Directory  "c:/wamp64/www/zend/public/">
        Options +Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require local
    </Directory>
</VirtualHost>

host is setup as 主机设置为

127.0.0.1       zend

I am trying to access the link as below 我正在尝试访问以下链接

http://zend/album http:// zend / album

C:\\wamp64\\www\\zend\\config\\modules.config.php C:\\ wamp64 \\ www \\ zend \\ config \\ modules.config.php

return [
    'Zend\Router',
    'Zend\Validator',
    'Application',
    'Album',
];

It was because of cache. 这是因为缓存。

Just disabled the below in C:\\wamp64\\www\\zend\\config\\application.config.php 只需在C:\\ wamp64 \\ www \\ zend \\ config \\ application.config.php中禁用以下内容

'config_cache_enabled' => false,
'module_map_cache_enabled' => false

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM