Slim3 I want to automatically load the corresponding class file via URI
we know
Container Resolution You are not limited to defining a function for your routes. In Slim there are a few different ways to define your route action functions.
In addition to a function, you may use:
container_key:method
Class:method
An invokable class
container_key
This functionality is enabled by Slim’s Callable Resolver Class. It translates a string entry into a function call. Example:
$app->get('/', '\HomeController:home');
Alternatively, you can take advantage of PHP’s ::class
operator which works well with IDE lookup systems and produces the same result:
$app->get('/', \HomeController::class . ':home');
In this code above we are defining a /
route and telling Slim to execute the home() method on the HomeController class.
But I want to implement this: load the corresponding class file by URI
example:
$app->get('[/{params:.*}]', '\{params1}:{params2}');
URI = /App/MyClass routes function = \App\MyClass
How can I achieve it? Thank you.