Вопрос

in ZF2 skeleton, router configuration uses a key :

'__NAMESPACE__' 

precisely :

'__NAMESPACE__' => 'Application\Controller',

cf: https://github.com/zendframework/ZendSkeletonApplication/blob/master/module/Application/config/module.config.php#l32

We tried in our modules router config to use without quote:

__NAMESPACE__ => 'Application\Controller',

but it seems to break configuration.

why do we use quote instead of

 __NAMESPACE__

to get its value ?

Это было полезно?

Решение

because by default, config files hasn't namespace declared. Config parser can read string

'__NAMESPACE__'

and determine correctly the namespace.

If you want to use it without quotes, you can declare in your config file :

namespace Application;

and use __NAMESPACE__ without quote.

That's why you can see sometimes in tutorials for Doctrine config's sample like :

    'doctrine'        => array(
    'driver' => array(
        'application_entity' => array(
            'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
            'paths' => __DIR__ . '/../src/' . __NAMESPACE__ . '/Entity',
        ),
        'orm_default'  => array(
            'drivers' => array(
                __NAMESPACE__ . '\Entity' => 'application_entity',
            )
        )
    )
),
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top