Routing & Controllers
Core Class: Router
Example: Defining Routes & Controllers
Base uses FastRoute for routing.
Defining routes
use Stilmark\Base\Router;
$router = new Router();
$router->dispatch();Routes are defined in a callback passed to FastRoute\simpleDispatcher inside Router.
Controllers
Controllers extend the Controller base class.
use Stilmark\Base\Controller;
class HelloController extends Controller {
public function index() {
return $this->json(['message' => 'Hello World']);
}
}Middleware
Routes can include middleware that run before the controller action.
Last updated