Php Zend FrameWork 2相册教程错误:出现404错误,未找到页面
我遵循下面的教程来实现[skeleton application][1] 我已复制粘贴了教程中提供的所有代码,但出现以下错误: 发生404错误 找不到页面 路由无法匹配请求的URL 没有例外 我已经交叉检查了StackOverflow中的所有类似问题,但没有一个能够解决我的问题 有人能帮我吗 请查找以下代码:Php Zend FrameWork 2相册教程错误:出现404错误,未找到页面,php,zend-framework,zend-framework2,Php,Zend Framework,Zend Framework2,我遵循下面的教程来实现[skeleton application][1] 我已复制粘贴了教程中提供的所有代码,但出现以下错误: 发生404错误 找不到页面 路由无法匹配请求的URL 没有例外 我已经交叉检查了StackOverflow中的所有类似问题,但没有一个能够解决我的问题 有人能帮我吗 请查找以下代码: C:\wamp64\www\zend\module\Album\module.php <?php namespace Album; use Album\Model\AlbumTa
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';
}
}
vhost如下所示
<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>
我正在尝试访问以下链接
C:\wamp64\www\zend\config\modules.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',
),
),
);
return [
'Zend\Router',
'Zend\Validator',
'Application',
'Album',
];
'config_cache_enabled' => false,
'module_map_cache_enabled' => false
这是因为缓存 只是在C:\wamp64\www\zend\config\application.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',
),
),
);
return [
'Zend\Router',
'Zend\Validator',
'Application',
'Album',
];
'config_cache_enabled' => false,
'module_map_cache_enabled' => false
这是因为缓存 只是在C:\wamp64\www\zend\config\application.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',
),
),
);
return [
'Zend\Router',
'Zend\Validator',
'Application',
'Album',
];
'config_cache_enabled' => false,
'module_map_cache_enabled' => false
只是需要确认一下,您是否正确使用了ApacheWeb服务器?您是否按照它在最底部所说的做了,“如果您看到一个标准的Apache 404错误,那么您需要在继续之前修复.htaccess的使用情况。”您输入了什么url?你的vhost(wamp vhost)是什么。我已经在问题中添加了.htaccess、vhost和host信息。您能看看这是否合适吗?嗨,Alex,我已经在modules.config中添加了代码,我在其中注册了module,但您是否正确使用Apache Web服务器?您是否按照它在最底部所说的做了,“如果您看到一个标准的Apache 404错误,那么您需要在继续之前修复.htaccess的使用情况。”您输入了什么url?你的vhost(wamp vhost)是什么。我已经在问题中添加了.htaccess、vhost和host信息。你能看看这是否合适吗?嗨,Alex,我已经在modules.config中添加了代码,在那里我注册了moduleMan,因为这个愚蠢的
404
我损失了2天。谢谢你,阿洛特曼我为这愚蠢的404
损失了两天。多谢各位