1. Go to this page and download the library: Download marceauka/router 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/ */
marceauka / router example snippets
$router = new Router;
// Will respond to : /hello (en GET)
$router->get('hello', function () {
echo 'Hello world!';
});
// POST request
$router->post(...);
// PATCH request
$router->patch(...);
// GET and POST requests
$router->add(['GET', 'POST'], 'hello', ...);
// ... Or all HTTP verbs
$router->any('hello', ...);
// Chaining
$router->get('foo', ...)->get('bar', ...);
// ...or via a callback
$router->routes(function ($router) {
// Votre logique
});
// Will use REQUEST_URI and REQUEST_METHOD
$router->listen();
// You can spoof them with your own logic (Request library for example).
$router->listing('request', 'method');
$router->get('hello', function () {
echo 'Hello!';
})