Zend Framework 2路由无法正常运行Windows 7

时间:2015-11-25 22:09:56

标签: php zend-framework

我阅读了此处发布的所有问题,无法找到解决问题的方法。

我有windows 7,xampp,apache 2.4,php 5.6,zend framework 2

我创建了一个名为Application

的示例应用程序

这是我的.htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteRule ^.*$ index.php [NC,L]

我的配置文件看起来像这样

   'translator' => array(
        'locale' => 'en_US',
        'translation_file_patterns' => array(
            array(
                'type'     => 'gettext',
                'base_dir' => __DIR__ . '/../language',
            'pattern'  => '%s.mo',
        ),
    ),
),
'controllers' => array(
    'invokables' => array(
        'Application\Controller\Login' => 'Application\Controller\LoginController',
        'Application\Controller\Index' => 'Application\Controller\IndexController'
    ),
),

http://localhost:8080/lizziap/这有效

localhost:8080 / lizziap / Index这不起作用

localhost:8080 / lizziap /登录此功能不起作用

localhost:8080 /索引这不起作用

找不到网页。 路由无法匹配请求的URL。

没有例外

我真的很感激任何帮助......谢谢!

这就是配置现在看起来如何工作

'router' => array(
    'routes' => array(
        'login' => array(
            'type' => 'segment',
            'options' => array(
                'route'    => '/login[/:action][/:id]',
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',
                    'id'=>'[0-9a-zA-Z]*',
                ),
                'defaults' => array(
                    'controller' => 'Application\Controller\Login',
                    'action'     => 'login',

                ),
            ),
        ),
        'home' => array(
            'type' => 'Zend\Mvc\Router\Http\Literal',
            'options' => array(
                'route'    => '/',
                'defaults' => array(
                    'controller' => 'Application\Controller\Index',
                    'action'     => 'index',
                ),
            ),
        ),

1 个答案:

答案 0 :(得分:1)

也许我的配置文件可以帮到你:

return array(
'controllers' => array(
    'invokables' => array(
        'Auth\Controller\Auth' => 'Auth\Controller\AuthController',
        'Auth\Controller\Success' => 'Auth\Controller\SuccessController',
    ),
),   
'router' => array(
    'routes' => array(
        'auth' => array(
            'type' => 'segment',
            'options' => array(
                'route'    => '/auth[/:action][/:id]', 
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',  
                    'id'=>'[0-9a-zA-Z]*',                        
                ),
                'defaults' => array(
                    'controller' => 'Auth\Controller\Auth',
                    'action'     => 'index',

                ),
            ),
        ),
        'success' => array(
            'type' => 'segment',
            'options' => array(
                'route'    => '/success[/:action]', 
                'constraints' => array(
                    'action' => '[a-zA-Z][a-zA-Z0-9_-]*',

                ),
                'defaults' => array(
                    'controller' => 'Auth\Controller\Success',
                    'action'     => 'index',

                ),
            ),
        ),
    ),

),

'view_manager' => array(
    'template_path_stack' => array(
        'auth' => __DIR__.'/../view',
    ),
),

);