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
Endpoint
in aRoute
file. Endpoint
calls aMiddleware
to handle the Authentication.Endpoint
calls its correspondingController
function.- The
Request
object, which is injected in theController
, applies the request validation and authorization rules. Controller
calls anAction
and passes the data from theRequest
object to it.Action
executes the business logic or call as manyTasks
as needed.Tasks
execute reusable subsets of the business logic.Action
prepares the data to be returned to theController
, and may collect data from theTasks
if needed.Controller
builds the response using aView
orTransformer
, 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.