简体   繁体   中英

Zf2 Routing Issue

I am new in Zend Framework‎ 2 . i have downloaded zend-skeleton application its working fine.but when i created new module of album & calling album route page not found error(404) occurs .

I have tried to apply many types of zf2 routes but same error message.

This is the error page which is being displayed again & again when i access album route :

在此处输入图片说明

I don't know why this error is being occurred? Kindly suggest me any solution?

Try to check your Module.php it should look something like this

public function getConfig()
{
    return include __DIR__ . '/config/module.config.php';
}

public function getAutoloaderConfig()
{
    return array(
        'Zend\Loader\StandardAutoloader' => array(
            'namespaces' => array(
                __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
            ),
        ),
    );
}

especially check namespace in all module files your module.config.php should look like this

'controllers' => array(
    'invokables' => array(
        'index' => 'Album\Controller\IndexController',
    ),
),

'router' => array(
    'routes' => array(
        'album' => array(
            'type' => 'literal',
            'options' => array(
                'route'    => '/album',
                'defaults' => array(
                    'controller' => 'index',
                    'action'     => 'index',
                ),
            ),


        ),
    ),
),

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

I hope, it will help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM