PHP code example of uwebpro / wp-rest-router
1. Go to this page and download the library: Download uwebpro/wp-rest-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/ */
uwebpro / wp-rest-router example snippets
use UWebPro\WordPress\Rest\Router;
//Example one
$router->get('/endpoint')->uses($callback);
//Example two
$router->get('/endpoint', $callback);
//With Parameters
$router->get('/endpoint/{parameter_one}/{?optional_parameter}')->uses($callback);
//Usage
$router->get('/navigation')->uses(function()
{
// processing
return new \WP_REST_Response(['data here']); // response;
});