1. Go to this page and download the library: Download guinso/hx-route library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
guinso / hx-route example snippets
// method options: GET, POST, PUT, DELETE, or any standard HTTP method
//$inputData specification can read from hx-http
//$inputData = array(
// "data" => .... client input value
// "file" => ... client upload file path value
//);
$routeConfigure = array(
new \Hx\Route\Info("/your/customer/(\w+)", "GET", function($arg, $inputData) {
$urlArgument = $arg[0]; //this is value from URL argument (\w+)
//get general value
$clientSpecificKeyValue = $inputData["date"]["clientSpecificKey"];
//get temporary uploaded file path
$clientUploadFilePath = $inputData["file"]["clientSpecificFileName"];
},
new \Hx\Route\Info("/another/custom/path", "POST", function($arg, $inputData) {
//handle another request
}
);
//initialize URL routing handler
$router = new \Hx\Route\RestRouter(
new \Hx\Route\Mapper($routeConfigure),
new \Hx\Http\HeaderReader(),
new \Hx\Http\InputService());
$router->run(); //start process incoming request URL