我正在尝试用我自己的覆盖核心 Symfony 组件。我使用的方法是:
"autoload": {
"psr-0": {
"": "src/",
"Symfony": "src/vendor/symfony/src/"
}
}
但是,当我运行 composer update 并安装时,它似乎从未考虑到这一点。这不是强制自动加载器在 Symfony 核心之前先查看另一个目录的正确方法吗?
任何指针表示赞赏!
编辑:文件路径
src/vendor/symfony/src/Symfony/Bridge/Twig/Extension/TranslationExtension.php
src/vendor/symfony/src/Symfony/Component/Translation/Translator.php src/vendor/symfony/src/Symfony/Component/Translation/Loader/YamlFileLoader.php
<?php
// autoload_namespaces.php generated by Composer
$vendorDir = dirname(__DIR__);
$baseDir = dirname($vendorDir);
return array(
'Twig_Extensions_' => $vendorDir . '/twig/extensions/lib/',
'Twig_' => $vendorDir . '/twig/twig/lib/',
'Symfony\\Bundle\\SwiftmailerBundle' => $vendorDir . '/symfony/swiftmailer-bundle/',
'Symfony\\Bundle\\MonologBundle' => $vendorDir . '/symfony/monolog-bundle/',
'Symfony\\Bundle\\AsseticBundle' => $vendorDir . '/symfony/assetic-bundle/',
'Symfony' => array($vendorDir . '/symfony/symfony/src/', '/src/vendor/symfony/src/'),
'SessionHandlerInterface' => $vendorDir . '/symfony/symfony/src/Symfony/Component/HttpFoundation/Resources/stubs',
'Sensio\\Bundle\\GeneratorBundle' => $vendorDir . '/sensio/generator-bundle/',
'Sensio\\Bundle\\FrameworkExtraBundle' => $vendorDir . '/sensio/framework-extra-bundle/',
'Sensio\\Bundle\\DistributionBundle' => $vendorDir . '/sensio/distribution-bundle/',
'Monolog' => $vendorDir . '/monolog/monolog/src/',
'Metadata\\' => $vendorDir . '/jms/metadata/src/',
'JMS\\SecurityExtraBundle' => $vendorDir . '/jms/security-extra-bundle/',
'JMS\\DiExtraBundle' => $vendorDir . '/jms/di-extra-bundle/',
'JMS\\AopBundle' => $vendorDir . '/jms/aop-bundle/',
'Doctrine\\ORM' => $vendorDir . '/doctrine/orm/lib/',
'Doctrine\\DBAL' => $vendorDir . '/doctrine/dbal/lib/',
'Doctrine\\Common' => $vendorDir . '/doctrine/common/lib/',
'Doctrine\\Bundle\\DoctrineBundle' => $vendorDir . '/doctrine/doctrine-bundle/',
'CG\\' => $vendorDir . '/jms/cg/src/',
'Assetic' => $vendorDir . '/kriswallsmith/assetic/src/',
'' => $baseDir . '/src/',
);
如果我手动将自动加载行编辑为:
'Symfony' => array('/Users/macbook/Sites/Opia/Gaia/src/vendor/symfony/src/', $vendorDir . '/symfony/symfony/src/'),
一切都按预期工作。所以现在它基本上是找到为什么作曲家不能正确作曲的解决方案。
编辑2:
做一些更多的搜索,上面的方法似乎不是一个好的实现:
https://groups.google.com/forum/#!msg/composer-dev/HprRV_wJZg4/M_zQ8O7lB6IJ
相反,我需要扩展给定的类并告诉 Symfony 使用这些类,这应该可以通过参数实现:
parameters:
security.authentication.listener.anonymous.class: Acme\DemoBundle
\Security\Http\Firewall\AcmeAnonymousAuthenticationListener
但是我不确定我需要设置哪些参数来加载扩展类来代替核心。