每当我尝试清除控制台上的缓存时,都会收到以下错误:
[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 不确定您要查找哪个文件...
最佳答案
例如,要在 CLI 中手动创建作用域“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');
}
}
}
关于Symfony 2 - 无法清除缓存 - 您无法创建非事件范围 ("request")的服务 ("request"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11405202/