dongtangu8403 2014-07-25 06:16
浏览 39
已采纳

在zend 2框架应用程序中请求url上找不到页面

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

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.

here code

  1. application.config

     return array(
    
     'modules' => array(
     'Application','Album',
     ),
    
    'module_paths' => array(
    './module',
    './vendor',
    ),
    
    'config_glob_paths' => array(
    'config/autoload/{,*.}{global,local}.php',
     ),
    
      ),
        );
    
  2. module.config

     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',
                                 ),
                            ),
                        );
    
  3. Module.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);
        },
       ),
       );
       }
        }
    
  4. 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>
    
  5. host entry at system32

      127.0.0.1:8081       zf2-tutorial.localhost
    

enter image description here

How can i handle it. Thanks

  • 写回答

4条回答 默认 最新

  • dqb14659 2014-07-25 11:08
    关注

    when you point with your apache document root to C:/xampp\htdocs/ZendSkeletonApplication/ZendSkeletonApplication-master/public

    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

    this url points internal to a different module/location.

    //edit

    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

    please check also your apache vhost entry if the port is equal to your windows host file port.

    make sure apache ModRewrite is loaded!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题