guinso / hx-route
HTTP REST router
Installs: 23
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/guinso/hx-route
Requires
- php: >=5.6
- guinso/hx-http: 1.0.*
This package is not auto-updated.
Last update: 2025-10-11 23:54:05 UTC
README
Simple HTTP routing utility. Can use for REST handler.
Install Package
Composer
//for PHP 7 { "require": { "guinso/hx-route": "2.0.*" } } //for PHP 5 { "require": { "guinso/hx-route": "1.0.*" } }
Manual
require_once("hx-route-directory/src/autoloader.php");
Example
// 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