whenever I try to clear the cache on the console I get the following error:
[Symfony\Component\DependencyInjection\Exception\InactiveScopeException]
You cannot create a service ("request") of an inactive scope ("request").
Has anyone experienced this before? Thanks.
Edit: Sample of code:
//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 Not sure which file you are looking for...
For example to manually create scope "request" in CLI you may overload the initializeContainer kernel method in AppKernel class, simply by doing:
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');
}
}
}
Fixed this problem by removing the request object in the constructor. As the CLI is headless there is no 'request' object unless it's manually created.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With