Slim DI Declare

I usually declare my routes this way

however I would like to declare them otherwise to take advantage of ide phpstorm’s features so that when it clicks it goes straight to the function

$app->get('', 'NotaEletronicaCtrl:index');

the other way would be

$app->get('', 'NotaEletronicaCtrl::class . ':index');

more as i do to declare with the join function

PhpStorm provides native support for this syntax:

$app->get('/', HomeIndexAction::class);

but this will only access the _construct () method if I need to access another method within the class

This will not only call the constructor. The __invoke method will also be called. This is called a “single action controller” => One Controller, One Action. Example

I was struggling with this hint problem also

only “solution” was using additional phpdoc annotations for that


/** @see NotaEletronicaCtrl::index() */ // note that it does not matter if method is static or not or of there are arguments
$app->get('', 'NotaEletronicaCtrl:index');

which will give you direct “click link” to method

1 Like