A REST PHP Routes class.
It uses the express (node.js) route concepts, in a very simple way.
This class needs the Friendly URL class as dependency and .htaccess file.
// URL = /version/1487 $url = new URL("http://localhost"); // Friendly URL class instance $api = new ROUTE($url, ['name' => "SHAW", 'version' => '1.0']); $api->define("/route/{{id}}", function ($api, $request) { $api->join($request); // you will see on the response an "id" position with "1487" as its value });Displays the API current Version
It merges an array with the response of the API. $status set the response status to true or false
It sets a new Route within a callback. You can set dynamic routes like this:
// URL = /version/1487 $api->define("/route/{{id}}", function ($api,$request) { $api->join($request); // you will see on the response an "id" position with "1487" as its value });It basically calls the API, to execute whatever that route should do.
It will send the response. if $echo == true, will print it on the screen, otherwise will return as a JSON object