发生Zend Framework 2相册教程404错误路由MAMP OSX无法匹配请求的URL [英] Zend Framework 2 Album Tutorial 404 error occurred The requested URL could not be matched by routing MAMP OSX

查看:91
本文介绍了发生Zend Framework 2相册教程404错误路由MAMP OSX无法匹配请求的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

也将其发布在IRC频道ZFTalk上,

just posted this on IRC channel ZFTalk too,

希望我可以使用MAMP获得有关ZF2,ZF2相册教程和OSX的帮助.骨架框架,主页正在运行.

Hope I can get some help on ZF2, ZF2 Album Tutorial, OSX using MAMP. Skeleton framework, homepage is working.

问题:完成部分:8.5列出相册后,您用一些代码填充了模块/相册/视图/相册/相册/index.phtml,然后他们要求您预览

Issue : After completing section : 8.5 Listing albums, you fill up the module/Album/view/album/album/index.phtml with some code, then they ask you to preview the page on http://zf2-tutorial.localhost/album.

我得到404,路由无法匹配所请求的URL.

I get a 404, The requested URL could not be matched by routing.

我前往Google寻求建议.找到了一个具有该教程的完全正常工作模型"的GIT存储库,因此我将其与我的代码进行了比较.如果我将此设置为另一台主机,则会收到相同的404路由消息.

I headed to Google for advice. Found a GIT repository with a 'fully working model' of the Tutorial, so i got this to compare my code with. If i set up this as another host I get the same 404 routing message.

仔细阅读本手册后,它明确指出,如果您的httpd.conf/AllowOverride未设置为FileInfo,则您将无法查看除开始/主页之外的任何内容.

After carefully studying the manual, it explicitly states in the start that you will not be able to view anything other than the start/home page if your httpd.conf / AllowOverride is not set to FileInfo.

决定在整个计算机上扫描名为httpd.conf的文件,以防万一在打开服务器电源时MAMP未使用我更改的文件的路径.

Decided to scan the whole machine for files called httpd.conf, just for in case the path to the one I changed is not used by MAMP when powering up the server.

因此找到了3个,将它们全部更改了(尽管我们找到了3个,我相信正确的路由是/private/etc)我的问题仍然存在于我在教程中编写的代码以及的GIT代码中. 工作模式".

So found 3, changed all of them (Although 3 we're found, I believe the correct route is /private/etc) My problem still exists in the code i wrote from the tutorial, as well as the GIT code of the 'working model'.

有人遇到过与此相关的问题吗?在stackoverflow Zend Framework 2 .htaccess mamp pro 上发现了这一点,它与我的相似之处问题,但尚未解决.这里有人可以帮助我吗?

Has anyone encountered issues with this? found this on stackoverflow Zend Framework 2 .htaccess mamp pro which has similarities to my problem but has not resolved it. Can anyone in here help me?

其他采取的途径包括:检查代码中的拼写错误,检查application.config.php是否设置了途径.请指教? :)

Other routes taken involve : Checking for spelling mistakes in the code, checking the application.config.php has a route set up. Please advise? :)

Module.php

Module.php

<?php
namespace Album;

use Album\Model\Album;
use Album\Model\AlbumTable;
use Zend\Db\ResultSet\ResultSet;
use Zend\Db\TableGateway\TableGateway;

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 getConfig()
    {
        return include __DIR__ . '/config/module.config.php';
    }

    public function getServiceConfig()
    {
        return array(
            'factories' => array(
                'Album\Model\AlbumTable' =>  function($sm) {
                    $tableGateway = $sm->get('AlbumTableGateway');
                    $table = new AlbumTable($tableGateway);
                    return $table;
                },
                'AlbumTableGateway' => function ($sm) {
                    $dbAdapter = $sm->get('Zend\Db\Adapter\Adapter');
                    $resultSetPrototype = new ResultSet();
                    $resultSetPrototype->setArrayObjectPrototype(new Album());
                    return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
                },
            ),
        );
    }
}

module.config.php

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

推荐答案

您可以解决的是通过在(httpd.conf)中配置apache设置来更改 从"AllowOverride None"到"AllowOverride All". 这样的设置允许您通过.htaccess覆盖配置值

You can solve is by configuring the apache settings in (httpd.conf) change the "AllowOverride None" to "AllowOverride All". Such setting permit you to override the config value by .htaccess

这篇关于发生Zend Framework 2相册教程404错误路由MAMP OSX无法匹配请求的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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