-1

私は zend フレームワークの初心者で、zend を構成しようとしています。Windows 7XAMPPに zendskeleton アプリケーションを正常にインストールしました

インストール後、ユーザーガイドの定義に従って新しいモジュールアルバムを作成しています。ガイドに従ってすべてのコードとページを作成しましたが、その後Album モジュールを開くことができました。エラー404が見つかりませんでした。

ここにコード

  1. アプリケーション.config

     return array(
    
     'modules' => array(
     'Application','Album',
     ),
    
    'module_paths' => array(
    './module',
    './vendor',
    ),
    
    'config_glob_paths' => array(
    'config/autoload/{,*.}{global,local}.php',
     ),
    
      ),
        );
    
  2. モジュール.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. system32でのホスト エントリ

      127.0.0.1:8081       zf2-tutorial.localhost
    

ここに画像の説明を入力

どうすればそれを処理できますか。ありがとう

4

4 に答える 4

2

ApacheドキュメントルートでポイントするとC:/xampp\htdocs/ZendSkeletonApplication/ZendSkeletonApplication-master/public

http://zf2-tutorial.localhost:8081/album あなたが書いたようではなく、ブラウザでこのURLを使用する必要がありますhttp://zf2-tutorial.localhost/ZendSkeletonApplication/ZendSkeletonApplication-master/public/album

この URL は内部で別のモジュール/場所を指しています。

//編集

これが機能しない場合は、ファイルが存在する場合は zf2/publicフォルダーを確認してください。.htaccessそうでない場合は、こちらの zend スケルトン アプリケーションのファイルを使用してください https://github.com/zendframework/ZendSkeletonApplication/blob/master/public/.htaccess

がファイル ポートと等しいapache vhost場合は、エントリも確認してください。portwindows host

ApacheModRewriteがロードされていることを確認してください!

于 2014-07-25T11:08:05.787 に答える
1

セットアップの基本的な設定ミスにより、このエラーが発生します。

  1. 私は長い間ウィンドウを使用していませんが、パスにフォワードとバックスラッシュの両方を使用しています。まず、Windows の正しいディレクトリ セパレータを見つけて、それを使い続ける必要があります。これは問題があるようです:C:/xampp\htdocs/foo/bar/public
  2. 81ポート(*:81) で任意の IP アドレスをリッスンする仮想ホストを定義しています。system32 ホスト エントリはポート8081をエイリアスとしてポイントし、 port を使用して url をzf2-tutorial.localhost呼び出そうとしています。この種のエラーが発生するのはごく普通のことです。zf2-tutorial.localhost/album80

公式のGetting StartedUsing Apache Web Serverのドキュメントを完全に読んだら、ソリューションを簡単に理解できるでしょう。

于 2014-07-25T12:15:11.050 に答える
0

このホストファイル エントリが必要です。このファイルにポートを追加することはできません。

127.0.0.1 zf2-tutorial.localhost

Web サイトは zf2-tutorial.localhost:81 で利用できるようになりました (8081 ではなく、httpd-vhosts.conf の最初の行でポート番号として 81 を設定します)。

于 2014-07-25T11:40:38.327 に答える