問題描述
我是 zend 框架的新手,我正在嘗試配置 zend.我在 window 7 和 XAMPP
I am newbie to zend framework and i am trying to configure the zend. I was sucessfully installed zendskeleton applicaion on window 7 and XAMPP
安裝后,我正在按照用戶指南中的定義創建新模塊相冊.我根據指南制作了所有代碼和頁面,但之后我可以打開相冊模塊.我收到錯誤 404 未找到.
After installation I am creating new module Album as per define in user guide. I was make all code and pages according to guide, but after that i was enable to open Album module. i got error 404 not found.
這里是代碼
application.config
return array(
'modules' => array(
'Application','Album',
),
'module_paths' => array(
'./module',
'./vendor',
),
'config_glob_paths' => array(
'config/autoload/{,*.}{global,local}.php',
),
),
);
module.config
return array(
'controllers' => array(
'invokables' => array(
'AlbumControllerAlbum' => 'AlbumControllerAlbumController',
),
),
'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' => 'AlbumControllerAlbum',
'action' => 'index',
),
),
),
),
),
'view_manager' => array(
'template_path_stack' => array(
'album' => __DIR__ . '/../view',
),
),
);
Module.php
namespace Album;
// Add these import statements:
use AlbumModelAlbum;
use AlbumModelAlbumTable;
use ZendDbResultSetResultSet;
use ZendDbTableGatewayTableGateway;
class Module
{
// getAutoloaderConfig() and getConfig() methods here
// Add this method:
public function getServiceConfig()
{
return array(
'factories' => array(
'AlbumModelAlbumTable' => function($sm) {
$tableGateway = $sm->get('AlbumTableGateway');
$table = new AlbumTable($tableGateway);
return $table;
},
'AlbumTableGateway' => function ($sm) {
$dbAdapter = $sm->get('ZendDbAdapterAdapter');
$resultSetPrototype = new ResultSet();
$resultSetPrototype->setArrayObjectPrototype(new Album());
return new TableGateway('album', $dbAdapter, null, $resultSetPrototype);
},
),
);
}
}
httpd-vhosts.conf
<VirtualHost *:81>
ServerName zf2-tutorial.localhost
DocumentRoot "C:/xampphtdocs/ZendSkeletonApplication/ZendSkeletonApplication-master/public"
SetEnv APPLICATION_ENV "development"
<Directory C:/xampphtdocs/ZendSkeletonApplication/ZendSkeletonApplication-master/public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
system32
127.0.0.1:8081 zf2-tutorial.localhost
我該如何處理.謝謝
推薦答案
當您將 apache 文檔根目錄指向 C:/xampphtdocs/ZendSkeletonApplication/ZendSkeletonApplication-master/public
when you point with your apache document root to C:/xampphtdocs/ZendSkeletonApplication/ZendSkeletonApplication-master/public
你需要在瀏覽器中使用這個 url http://zf2-tutorial.localhost:8081/album
而不是像你寫的 http://zf2-tutorial.localhost/ZendSkeletonApplication/ZendSkeletonApplication-master/public/album
you need to use in your browser this url http://zf2-tutorial.localhost:8081/album
and not like you wrote http://zf2-tutorial.localhost/ZendSkeletonApplication/ZendSkeletonApplication-master/public/album
此 url 指向內部不同的模塊/位置.
this url points internal to a different module/location.
//編輯
如果這不起作用,請檢查您的 zf2 /public
文件夾,如果存在 .htaccess
文件,否則請在此處使用來自 zend 框架應用程序的文件 https://github.com/zendframework/ZendSkeletonApplication/blob/master/public/.htaccess
if this not work check your zf2 /public
folder if there is a .htaccess
file present otherwise use the file from the zend skeleton application here https://github.com/zendframework/ZendSkeletonApplication/blob/master/public/.htaccess
如果 port
等于您的 windows 主機
文件端口,請同時檢查您的 apache vhost
條目.
please check also your apache vhost
entry if the port
is equal to your windows host
file port.
確保 apache ModRewrite
已加載!
make sure apache ModRewrite
is loaded!
這篇關于在 Zend 2 框架應用程序中的請求 url 上找不到頁面的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!