First route "callable not found"


I’m doing my first steps in Slim and PHP trying to improve an existing app with new features.

$app->group('/admin', function () {


$this->get('/incident', 'IncidentController:main')->setName('admin-incident-main');
    $this->get('/incident/retrieve[/{page:[0-9]+}[/{query}]]', 'IncidentController:retrieve')->setName('admin-incident-retrieve');


final class IncidentController
    const MAIL_RECIPIENT = 'something@domain.tld';

    private $view;
    private $client;

    public function __construct(PhpRenderer $view, Client $client)
        $this->view = $view;
        $this->client = $client;

    public function main(ServerRequestInterface $request, ResponseInterface $response)
        return $this->view->render($response, 'incident/main.phtml');

incident/main.phtml is a copy of another page which already works through different routes. I could use the other response simply using another .phtml, but I think this isn’t the error here

However if I’m trying to access domain.tld/admin/incident:

Type: RuntimeException
Message: Callable IncidentController does not exist
File: C:\Users\$USER\Documents\$PROJECTNAME\vendor\slim\slim\Slim\CallableResolver.php
Line: 62

So far I know the $this->get('/incident', 'IncidentController:main [...] in routes.php should call the main procedure in app/Web/Controller/IncidentController.php where the file should be according to the Slim Docs.
This Controller should simply output /app/views/incident/main.phtml (which can be a “Hello world” text-output too in this stage) - but the Controller itself isn’t found.

Did I miss something? Does Slim need to get to know the Controller elsewhere and not only in routes.php?


I set up a dependency in dependencies.php and now it works. I don’t quite know why that was required…