Symfony配置组件,带有yaml的setArgument

时间:2014-03-28 23:00:32

标签: php symfony yaml

我正试图转换这个php配置

$container->register('framework', 'Symfony\Component\HttpKernel\HttpKernel')
->setArguments(array(new Reference('dispatcher'), new Reference('resolver')));

进入yaml语法,我已经很好地使用了调度程序和解析器,但现在无法理解如何将参数传递给HttpKernel构造函数,我已经尝试过了

framework:
    class:    Symfony\Component\HttpKernel\HttpKernel
    arguments:  ["dispatcher", "resolver"]


framework:
    class:    Symfony\Component\HttpKernel\HttpKernel
    arguments:  [dispatcher, resolver]

但我收到错误

Catchable fatal error: Argument 1 passed to Symfony\Component\HttpKernel\HttpKernel::__construct() must be an instance of Symfony\Component\EventDispatcher\EventDispatcherInterface, string given in

1 个答案:

答案 0 :(得分:0)

解决,必须

framework:
    class:    Symfony\Component\HttpKernel\HttpKernel
    arguments:  ["@dispatcher", "@resolver"]

注意 @