Request Lifecycle
When using any tool in the "real world", you feel more confident if you understand how that tool works. Application development is no different. When you understand how your development tools function, you feel more comfortable and confident using them.
The following steps describe a basic API call scenario:
- The User calls an
Endpointin aRoutefile. Endpointcalls aMiddlewareto handle the Authentication.Endpointcalls its correspondingControllerfunction.- The
Requestobject, which is injected in theController, applies the request validation and authorization rules. Controllercalls anActionand passes the data from theRequestobject to it.Actionexecutes the business logic or call as manyTasksas needed.Tasksexecute reusable subsets of the business logic.Actionprepares the data to be returned to theController, and may collect data from theTasksif needed.Controllerbuilds the response using aVieworTransformer, and sends it back to the User.
It is important to note that the Request object handles request validation and authorization rules,
while the Action executes the business logic.
The Tasks can be used to execute reusable subsets of the business logic,
with each Task responsible for a single portion of the main Action.
The View or Transformer is used to build the response that is sent back to the User.