每当我试图清除控制台上的缓存时,我都会得到以下错误:
[Symfony\Component\DependencyInjection\Exception\InactiveScopeException]
You cannot create a service ("request") of an inactive scope ("request").以前有没有人经历过这种情况?谢谢。
编辑:代码示例:
//accessing request object
namespace Greg\TestBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\DependencyInjection\ContainerInterface;
use HvH\APIschemaBundle\Controller\Validation;
use HvH\APIschemaBundle\Controller\Helpers;
//FOSRestBundle
use FOS\RestBundle\View\View;
class TestController extends Controller
{
public function testAction(Request $request)
{
//get any query strings
$query_strings = $request->query->all();
return($query_strings);
}
}XML不确定您要查找的文件...
发布于 2013-03-03 12:08:55
例如,要在命令行界面中手动创建作用域"request“,您可以重载AppKernel类中的initializeContainer内核方法,只需执行以下操作:
class AppKernel extends Kernel {
public function registerBundles() {
// ...
}
public function registerContainerConfiguration(LoaderInterface $loader) {
// ...
}
protected function initializeContainer() {
parent::initializeContainer();
if (PHP_SAPI == 'cli') {
$this->getContainer()->enterScope('request');
$this->getContainer()->set('request', new \Symfony\Component\HttpFoundation\Request(), 'request');
}
}
}https://stackoverflow.com/questions/11405202
复制相似问题