404 请求的 URL 无法通过路由匹配 [英] 404 The requested URL could not be matched by routing

查看:34
本文介绍了404 请求的 URL 无法通过路由匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始学习 在 评论.

缺失链接a href="http://framework.zend.com/manual/2.3/en/user-guide/skeleton-application.html" rel="nofollow noreferrer">zend 骨架应用程序 和 路由和控制器所在的初始模块结构和模块文件代码写好了.

我的 Module.php 中的代码丢失了

使用 Zend\ModuleManager\Feature\AutoloaderProviderInterface;使用 Zend\ModuleManager\Feature\ConfigProviderInterface;类模块实现 AutoloaderProviderInterface、ConfigProviderInterface {公共函数 getAutoloaderConfig(){返回数组('Zend\Loader\StandardAutoloader' =>大批('命名空间' =>大批(__命名空间__ =>__DIR__ .'/src/' .__命名空间__,),),);}公共函数 getConfig() {返回包括 __DIR__ .'/config/module.config.php';}}

I'd just started to learn and following this user guide.

I'm able to successfully install the zend skeleton application and moved on to the routing and controllers. But after completion of the tutorial I requested the url: http://zf2-tutorial.localhost/album in my browser and I'm getting 404.

I'd looked down into the comments where some people saying about changes in

'route' => '/album[/][:action][/:id]'

needs to be

'route' => '/album[/:action][/:id]'

but that doesn't help either. Can anyone help me in resolving the issue?

Directory structure:

解决方案

thanks to Crisp for mentioning the url in comment.

there is a missing link between zend skeleton application and routing and controllers where the initial module structure and module file code is written.

the code in my Module.php was missing is

use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ConfigProviderInterface;
class Module implements AutoloaderProviderInterface, ConfigProviderInterface {
    public function getAutoloaderConfig()
     {
         return array(
             'Zend\Loader\StandardAutoloader' => array(
                 'namespaces' => array(
                     __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
                 ),
             ),
         );
     }
    public function getConfig() {
        return include __DIR__ . '/config/module.config.php';
    }
}

这篇关于404 请求的 URL 无法通过路由匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆