Trying to inject SymfonyComponentHttpFoundationResponse into controller method
namespace AppController;
use SymfonyBundleFrameworkBundleControllerAbstractController;
use SymfonyComponentHttpFoundationRequest;
use SymfonyComponentHttpFoundationResponse;
use SymfonyComponentHttpKernelAttributeAsController;
use SymfonyComponentRoutingAnnotationRoute;
#[AsController]
class TestController extends AbstractController
{
#[Route(path: 'test', name: 'test', methods: ['GET'])]
public function test(Request $request, Response $response) : Response
{
return $response->setContent("Hello!");
}
}
But get an error
Could not resolve argument $response of "AppControllerTestController::test()", maybe you forgot
to register the controller as a service or missed tagging it with the controller.service_arguments;?
(500 Internal Server Error)
Debug php bin/console debug:autowiring --all shows, that container have Response
...
Request represents an HTTP request.
SymfonyComponentHttpFoundationRequest
Response represents an HTTP response.
SymfonyComponentHttpFoundationResponse
...
Why request injected, but Response not?