The basic flow
When an HTTP request is received, it first hits your predefined Endpoint (each endpoint live in its own Route file).
Sample Route Endpoint
'uses' => 'Controller@sayHello',
After the user makes a request to the endpoint
[GET] www.api.apiato.com/v1/hello it calls the defined controller
Sample Controller Function
class Controller extends ApiController
public function sayHello(SayHelloRequest $request)
$helloMessage = Apiato::call(SayHelloAction::class);
This function takes a Request class
SayHelloRequest to automatically checks if the user has the right access to this
endpoint. Only if the user has access, it proceeds to the function body.
Then the function calls an Action (
SayHelloAction) to perform the business logic.
class SayHelloAction extends Action
public function run()
return 'Hello World!';
The Action can do anything then return a result (could be an Object, a String or anything).
When the Action finishes its job, the controller function gets ready to build a response.
Json responses can be built using the helper function
$this->json(['foo' => 'bar']);).
Sample User Response