So if your application starts small and grows, it is easy to modify the application routes acting as a micro framework to a full-stack style.
You can skip to your favourite usage.
The following is an example of a micro-framework style route, where the action logic is embedded in the route params. In the modify() config method, we retrieve the shared aura/web-kernel:request and aura/web-kernel:response services, along with the aura/web-kernel:router service. We then add a route names blog.read and embed the action code as a closure.
Modified Micro-Framework Style
We can modify the above example to put the action logic in the dispatcher instead of the route itself.
Extract the action closure to the dispatcher under the name blog.read. Then, in the route, use a action value that matches the name in the dispatcher.
You can migrate from a micro-framework style to a full-stack style (or start with full-stack style in the first place).
First, define a action class and place it in the project src/ directory.
Next, tell the project how to build the BlogRead through the DI Container. Edit the project config/Common.php file to configure the Container to pass the aura/web-kernel:request and aura/web-kernel:response service objects to the BlogRead constructor.
After that, put the App\Actions\BlogRead object in the dispatcher under the name blog.read as a lazy-loaded instantiation …
… and finally, point the router to the blog.read action object: