}
try {
$callable = $this->createController($controller);
} catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e);
}
if (!\is_callable($callable)) {
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$this->getControllerError($callable));
}
public function getController(Request $request): callable|false
{
$e = $this->stopwatch->start('controller.get_callable');
try {
return $this->resolver->getController($request);
} finally {
$e->stop();
}
}
}
if ($event->hasResponse()) {
return $this->filterResponse($event->getResponse(), $request, $type);
}
// load controller
if (false === $controller = $this->resolver->getController($request)) {
throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo()));
}
$event = new ControllerEvent($this, $controller, $request, $type);
$this->dispatcher->dispatch($event, KernelEvents::CONTROLLER);
{
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
$this->requestStack->push($request);
try {
return $this->handleRaw($request, $type);
} catch (\Throwable $e) {
if ($e instanceof \Error && !$this->handleAllThrowables) {
throw $e;
}
$this->boot();
++$this->requestStackSize;
$this->resetServices = true;
try {
return $this->getHttpKernel()->handle($request, $type, $catch);
} finally {
--$this->requestStackSize;
}
}
$this->request = $request;
}
public function run(): int
{
$response = $this->kernel->handle($this->request);
$response->send();
if ($this->kernel instanceof TerminableInterface) {
$this->kernel->terminate($this->request, $response);
}
$app = $app(...$args);
exit(
$runtime
->getRunner($app)
->run()
);
<?php
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
if ($e instanceof \ArgumentCountError) {
throw new \InvalidArgumentException(sprintf('Controller "%s" has required constructor arguments and does not exist in the container. Did you forget to define the controller as a service?', $class), 0, $e);
}
throw new \InvalidArgumentException(sprintf('Controller "%s" does neither exist as service nor as class.', $class), 0, $e);
}
private function throwExceptionIfControllerWasRemoved(string $controller, \Throwable $previous)
{
if ($this->container instanceof Container && isset($this->container->getRemovedIds()[$controller])) {
*/
class ControllerResolver extends ContainerControllerResolver
{
protected function instantiateController(string $class): object
{
$controller = parent::instantiateController($class);
if ($controller instanceof ContainerAwareInterface) {
$controller->setContainer($this->container);
}
if ($controller instanceof AbstractController) {
}
[$class, $method] = explode('::', $controller, 2);
try {
$controller = [$this->instantiateController($class), $method];
} catch (\Error|\LogicException $e) {
try {
if ((new \ReflectionMethod($class, $method))->isStatic()) {
return $class.'::'.$method;
}
if (\function_exists($controller)) {
return $controller;
}
try {
$callable = $this->createController($controller);
} catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e);
}
if (!\is_callable($callable)) {
public function getController(Request $request): callable|false
{
$e = $this->stopwatch->start('controller.get_callable');
try {
return $this->resolver->getController($request);
} finally {
$e->stop();
}
}
}
if ($event->hasResponse()) {
return $this->filterResponse($event->getResponse(), $request, $type);
}
// load controller
if (false === $controller = $this->resolver->getController($request)) {
throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo()));
}
$event = new ControllerEvent($this, $controller, $request, $type);
$this->dispatcher->dispatch($event, KernelEvents::CONTROLLER);
{
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
$this->requestStack->push($request);
try {
return $this->handleRaw($request, $type);
} catch (\Throwable $e) {
if ($e instanceof \Error && !$this->handleAllThrowables) {
throw $e;
}
$this->boot();
++$this->requestStackSize;
$this->resetServices = true;
try {
return $this->getHttpKernel()->handle($request, $type, $catch);
} finally {
--$this->requestStackSize;
}
}
$this->request = $request;
}
public function run(): int
{
$response = $this->kernel->handle($this->request);
$response->send();
if ($this->kernel instanceof TerminableInterface) {
$this->kernel->terminate($this->request, $response);
}
$app = $app(...$args);
exit(
$runtime
->getRunner($app)
->run()
);
<?php
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
/**
* Returns an instantiated controller.
*/
protected function instantiateController(string $class): object
{
return new $class();
}
private function getControllerError(mixed $callable): string
{
if (\is_string($callable)) {
if ($this->container->has($class)) {
return $this->container->get($class);
}
try {
return parent::instantiateController($class);
} catch (\Error $e) {
}
$this->throwExceptionIfControllerWasRemoved($class, $e);
*/
class ControllerResolver extends ContainerControllerResolver
{
protected function instantiateController(string $class): object
{
$controller = parent::instantiateController($class);
if ($controller instanceof ContainerAwareInterface) {
$controller->setContainer($this->container);
}
if ($controller instanceof AbstractController) {
}
[$class, $method] = explode('::', $controller, 2);
try {
$controller = [$this->instantiateController($class), $method];
} catch (\Error|\LogicException $e) {
try {
if ((new \ReflectionMethod($class, $method))->isStatic()) {
return $class.'::'.$method;
}
if (\function_exists($controller)) {
return $controller;
}
try {
$callable = $this->createController($controller);
} catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException(sprintf('The controller for URI "%s" is not callable: ', $request->getPathInfo()).$e->getMessage(), 0, $e);
}
if (!\is_callable($callable)) {
public function getController(Request $request): callable|false
{
$e = $this->stopwatch->start('controller.get_callable');
try {
return $this->resolver->getController($request);
} finally {
$e->stop();
}
}
}
if ($event->hasResponse()) {
return $this->filterResponse($event->getResponse(), $request, $type);
}
// load controller
if (false === $controller = $this->resolver->getController($request)) {
throw new NotFoundHttpException(sprintf('Unable to find the controller for path "%s". The route is wrongly configured.', $request->getPathInfo()));
}
$event = new ControllerEvent($this, $controller, $request, $type);
$this->dispatcher->dispatch($event, KernelEvents::CONTROLLER);
{
$request->headers->set('X-Php-Ob-Level', (string) ob_get_level());
$this->requestStack->push($request);
try {
return $this->handleRaw($request, $type);
} catch (\Throwable $e) {
if ($e instanceof \Error && !$this->handleAllThrowables) {
throw $e;
}
$this->boot();
++$this->requestStackSize;
$this->resetServices = true;
try {
return $this->getHttpKernel()->handle($request, $type, $catch);
} finally {
--$this->requestStackSize;
}
}
$this->request = $request;
}
public function run(): int
{
$response = $this->kernel->handle($this->request);
$response->send();
if ($this->kernel instanceof TerminableInterface) {
$this->kernel->terminate($this->request, $response);
}
$app = $app(...$args);
exit(
$runtime
->getRunner($app)
->run()
);
<?php
use App\Kernel;
require_once dirname(__DIR__).'/vendor/autoload_runtime.php';
return function (array $context) {
return new Kernel($context['APP_ENV'], (bool) $context['APP_DEBUG']);
};
No log messages
[3/3]
InvalidArgumentException
|
---|
InvalidArgumentException: The controller for URI "/" is not callable: Controller "App\Controller\TestController" does neither exist as service nor as class. at vendor/symfony/http-kernel/Controller/ControllerResolver.php:76 at Symfony\Component\HttpKernel\Controller\ControllerResolver->getController() (vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php:36) at Symfony\Component\HttpKernel\Controller\TraceableControllerResolver->getController() (vendor/symfony/http-kernel/HttpKernel.php:146) at Symfony\Component\HttpKernel\HttpKernel->handleRaw() (vendor/symfony/http-kernel/HttpKernel.php:74) at Symfony\Component\HttpKernel\HttpKernel->handle() (vendor/symfony/http-kernel/Kernel.php:184) at Symfony\Component\HttpKernel\Kernel->handle() (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35) at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (vendor/autoload_runtime.php:29) at require_once('/home/appuser/app/vendor/autoload_runtime.php') (public/index.php:5) |
[2/3]
InvalidArgumentException
|
---|
InvalidArgumentException: Controller "App\Controller\TestController" does neither exist as service nor as class. at vendor/symfony/http-kernel/Controller/ContainerControllerResolver.php:54 at Symfony\Component\HttpKernel\Controller\ContainerControllerResolver->instantiateController() (vendor/symfony/framework-bundle/Controller/ControllerResolver.php:26) at Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver->instantiateController() (vendor/symfony/http-kernel/Controller/ControllerResolver.php:106) at Symfony\Component\HttpKernel\Controller\ControllerResolver->createController() (vendor/symfony/http-kernel/Controller/ControllerResolver.php:74) at Symfony\Component\HttpKernel\Controller\ControllerResolver->getController() (vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php:36) at Symfony\Component\HttpKernel\Controller\TraceableControllerResolver->getController() (vendor/symfony/http-kernel/HttpKernel.php:146) at Symfony\Component\HttpKernel\HttpKernel->handleRaw() (vendor/symfony/http-kernel/HttpKernel.php:74) at Symfony\Component\HttpKernel\HttpKernel->handle() (vendor/symfony/http-kernel/Kernel.php:184) at Symfony\Component\HttpKernel\Kernel->handle() (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35) at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (vendor/autoload_runtime.php:29) at require_once('/home/appuser/app/vendor/autoload_runtime.php') (public/index.php:5) |
[1/3]
Error
|
---|
Error: Class "App\Controller\TestController" not found at vendor/symfony/http-kernel/Controller/ControllerResolver.php:131 at Symfony\Component\HttpKernel\Controller\ControllerResolver->instantiateController() (vendor/symfony/http-kernel/Controller/ContainerControllerResolver.php:44) at Symfony\Component\HttpKernel\Controller\ContainerControllerResolver->instantiateController() (vendor/symfony/framework-bundle/Controller/ControllerResolver.php:26) at Symfony\Bundle\FrameworkBundle\Controller\ControllerResolver->instantiateController() (vendor/symfony/http-kernel/Controller/ControllerResolver.php:106) at Symfony\Component\HttpKernel\Controller\ControllerResolver->createController() (vendor/symfony/http-kernel/Controller/ControllerResolver.php:74) at Symfony\Component\HttpKernel\Controller\ControllerResolver->getController() (vendor/symfony/http-kernel/Controller/TraceableControllerResolver.php:36) at Symfony\Component\HttpKernel\Controller\TraceableControllerResolver->getController() (vendor/symfony/http-kernel/HttpKernel.php:146) at Symfony\Component\HttpKernel\HttpKernel->handleRaw() (vendor/symfony/http-kernel/HttpKernel.php:74) at Symfony\Component\HttpKernel\HttpKernel->handle() (vendor/symfony/http-kernel/Kernel.php:184) at Symfony\Component\HttpKernel\Kernel->handle() (vendor/symfony/runtime/Runner/Symfony/HttpKernelRunner.php:35) at Symfony\Component\Runtime\Runner\Symfony\HttpKernelRunner->run() (vendor/autoload_runtime.php:29) at require_once('/home/appuser/app/vendor/autoload_runtime.php') (public/index.php:5) |