To create new routes, define it in config/routes.php
.
You can use the standard components like in the compiled file config/Built/routes.php
. It is a great example to get you started with Slim 4 and the compiled runtime classes.
Try to keep your routes definition standard if you want to use the RouteHelper.
Standard url for non-api call: /${model}[[/${action}][/${id}]]
Standard url for api call: /api/v1/${model}[[/${action}][/${id}]]
Add route through Service
You can add a route, or action to a existing service, just add to the ‘customActions ‘array
class AccountServiceWrapper extends AccountService { public function __construct($request, $response, $args) { parent::__construct($request, $response, $args); $this->Form = new AccountsFormWrapper($request, $args); $this->customActions['refresh'] = 'refreshAccount'; } public function refreshAccount(){ $pubkey = $this->request['i']; return [ 'status' => 'success','messages' => "Account ".$this->request['i']."<br>".print_r($accountInfo, true) ]; }