Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在引导过程中(容器)在Symfony 2中加载额外服务_Symfony - Fatal编程技术网

在引导过程中(容器)在Symfony 2中加载额外服务

在引导过程中(容器)在Symfony 2中加载额外服务,symfony,Symfony,我收到以下错误消息: [22-Oct-2012 06:03:24] PHP Catchable fatal error: Argument 1 passed to Symfony\Component\DependencyInjection\Loader\FileLoader::__construct() must be an instance of Symfony\Component\DependencyInjection\ContainerBuilder, instance of plugi

我收到以下错误消息:

[22-Oct-2012 06:03:24] PHP Catchable fatal error:  Argument 1 passed to Symfony\Component\DependencyInjection\Loader\FileLoader::__construct() must be an instance of Symfony\Component\DependencyInjection\ContainerBuilder, instance of pluginsProdProjectContainer given, called in ....
在具体的一行,它是这样写的:

$loader = new XMLFileLoader($container, new FileLocator($config_path));
这似乎是SF2自动生成并加载一个缓存文件的结果,该文件为:pluginsProdProjectContainer.php,该文件似乎在扩展容器:

class pluginsProdProjectContainer extends Container

因此,当我将容器传递到XMLFileLoader中时,传递的是容器的实例,而不是ContainerBuilder。我不太清楚该怎么解决这个问题

您的问题可能是您正在尝试使用
Container
对象,但是
XMLFileLoader
希望
ContainerBuilder
对象作为第一个参数

在您的示例中,$Container是什么-如何构建/获取此对象?是在课堂上扩展扩展吗?你是对的,我想我应该在扩展中这样做。我是在boot()之后从$kernel获取容器的,它似乎总是返回该缓存类。您的问题可能是您正在尝试使用容器对象,但您的XMLFileLoader期望ContainerBuilder对象作为第一个参数您完全正确,我现在切换到在DI通道内执行此操作,以便可以访问ContainerBuilder。不知道我怎么能接受你的评论作为答案。我已经把它作为答案发布了。最好的!