Routing - Philiphil/Kult-Engine GitHub Wiki

How to use k\router

Router will soon be rewrite, compatibility with current rooter should be 100%

k\router is the rest class, in order to include it, use k\invoker::require_basics();

Everything wrote in a page will stay in this page, to create a global route : edit controller/impt/route.php and create global_route objects $exemple = k\global_route('*',function(){},'GET');

To write a page based route, use this method (parameters are the same that global_route object uses) k\router::set_route('*', function(){});

First arg is route, second is function to execute when route is achieved, third is method, by default its 'GET', you can set it to '*' meaning all.

How to write a route with exemple. rest.php will be the exemple page.

'' : everything will trigger this route '/' : rest.php/ will trigger this route '/user/' : rest.php/user/ will triger this route '/user/*' : is exactly the same as above '/user/|<1' : means that rest.php/user/whatever/ will trigger this route and that callback function will recieve whatever as parameter