Symfony在每个控制器上自动加载命名空间

时间:2016-07-15 09:05:48

标签: php namespaces components symfony

我已经看到Symfony中有一个autoload_namespace.php文件,但我似乎无法让它工作。

我想自动加载:Symfony \ Component \ HttpFoundation \ Session \ Session命名空间。

到目前为止,这是autoload_namespace.php

<?php

// autoload_namespaces.php @generated by Composer

$vendorDir = dirname(dirname(__FILE__));
$baseDir = dirname($vendorDir);

return array(
    'Twig_' => array($vendorDir . '/twig/twig/lib'),
    'SensioLabs\\Security' => array($vendorDir . '/sensiolabs/security-checker'),
    'Psr\\Log\\' => array($vendorDir . '/psr/log'),
    'Doctrine\\ORM\\' => array($vendorDir . '/doctrine/orm/lib'),
    'Doctrine\\DBAL\\' => array($vendorDir . '/doctrine/dbal/lib'),
    'Doctrine\\Common\\Lexer\\' => array($vendorDir . '/doctrine/lexer/lib'),
    'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'),
    'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib'),
    'Doctrine\\Common\\Annotations\\' => array($vendorDir . '/doctrine/annotations/lib'),
    //this is the session namespace i want to auto include
    'Symfony\\Component\\HttpFoundation\\Session\\Session\\' => array($vendorDir . '/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Session.php')
);

由于

0 个答案:

没有答案