我是 zend 框架的新手,我正在尝试配置 zend。我在窗口 7和XAMPP上成功安装了 zendskeleton 应用程序
安装后,我正在按照用户指南中的定义创建新模块专辑。我根据指南制作了所有代码和页面,但之后我可以打开专辑模块。我收到错误 404 未找到。
这里代码
应用程序.config
return array( 'modules' => array( 'Application','Album', ), 'module_paths' => array( './module', './vendor', ), 'config_glob_paths' => array( 'config/autoload/{,*.}{global,local}.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', ), ), );
模块.php
namespace Album; // Add these import statements: use Album\Model\Album; use Album\Model\AlbumTable; use Zend\Db\ResultSet\ResultSet; use Zend\Db\TableGateway\TableGateway; class Module { // getAutoloaderConfig() and getConfig() methods here // Add this method: 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); }, ), ); } }
httpd-vhosts.conf
<VirtualHost *:81> ServerName zf2-tutorial.localhost DocumentRoot "C:/xampp\htdocs/ZendSkeletonApplication/ZendSkeletonApplication-master/public" SetEnv APPLICATION_ENV "development" <Directory C:/xampp\htdocs/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
我该如何处理。谢谢