1. Go to this page and download the library: Download netrivet/wp-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/ */
netrivet / wp-router example snippets
use DownShift\WordPress\Router;
$router = new Router('my_scope');
// matches ?my_scope=/myroute
$router->post('/myroute', function () {
// do something here
});
// listen terminates via exit after route function executes
$router->listen();
$router->post('/myroute', new InvokableClass());
// or a string if you prefer
$router->post('/myroute', 'DownShift\Responders\SomeClass');
$container = new Container();
$container->bind('SomeInterface', 'SomeImplementation');
$router = new Router('my_scope');
$router->bind($container);
$router->get('/test', function (SomeInterface $service) {
// do a thing with $service
});
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.