Routing

To run a controller function method on a specific route path.

Request method type of GET

Setting a route with the request method type of get.


<?php

  use core\http\Route;

  new Route(['GET' => '/path'], ['Controller' => 'method']);
 

Request method type of POST

Setting a route with the request method type of post.


<?php

  use core\http\Route;

  new Route(['POST' => '/path'], ['Controller' => 'method']);
 

Controllers in subfolders

Controllers inside subfolders should be devided with backslashes.


<?php

  use core\http\Route;

  new Route(['GET' => '/path'], ['subfolder\Controller' => 'method']);
 

Route binding

Any value will match inside the url on the same string position as the setted route key in the route path. When the route key is set, this value will be passed inside the controller method as an argument as an associative array. The key value is the same as the setted route key.


<?php

  use core\http\Route;

  new Route(['GET' => '/path/[routeKey]'], ['Controller' => 'method']);