1. Go to this page and download the library: Download ivrok/wp-api-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/ */
ivrok / wp-api-router example snippets
use Ivrok\ShowUsers\Users\UsersAPIController;
use Ivrok\ShowUsers\Users\UsersService;
use Ivrok\WPAPIRouter\HTTPMethodsInterface;
use Ivrok\WPAPIRouter\WPAPIRoute;
use Ivrok\WPAPIRouter\WPAPIRouter;
$usersAPIController = new UsersAPIController(new UsersService());
$apiRouter = new WPApiRouter();
$apiRouter->addRoute(
new WPApiRoute(
HTTPMethodsInterface::METHODS["GET"],
"show-users/v1",
"/getAll",
[$usersAPIController, "getAll"]
)
);
$apiRouter->addRoute(
new WPApiRoute(
HTTPMethodsInterface::METHODS["GET"],
"show-users/v1",
"/get/(?P<id>\d+)",
[$usersAPIController, "getUser"]
)
);
$apiRouter->init();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.