i want to use Request class in my constructor and this is the error it gives to me while i want to run server:
Cannot autowire service "AppBundle\Controller\DetectServiceDetailController": argument "$request" of method "__construct()" references class "Symfony\Component\HttpFoundation\Request" but no such service exists. It cannot be auto-registered because it is from a different root namespace.
my code:
<?php
namespace AppBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
class DetectServiceDetailController
{
public $request;
public function __construct(Request $request)
{
$this->request = $request;
$serviceType = $this->request->query->get('type');
return $serviceType;
}
}
RequestStack
class instead ofRequest
. – gp_sfloverRequest
right into controller methods. – Alex Karshin