Controllers are entry points into your application that make sense for humans beings in modern web applications. The way of routing request to a Controller is usually by analyzing the application URL for each request.
The main use case of Controllers in Strata is to replace the need of placing pure code in template file. Instead of instantiating queries and various variables inside a template file, you should place this code in a Controller. The biggest and most obvious gain is the ability to use the same business logic code multiple times as well as improving code testability and readability.
Creating a controller file
To generate a Controller, you should use the automated generator provided by Strata. It will validate your object’s name and ensure it is defined following the intended conventions.
Using the command line, run the
generate command from your project’s base directory. In this example, we will generate a controller for the
The command generates a couple of files for you, including the actual Controller file and test suites for the generated class.