Skip to content

willpercey-gb/wp-rest-router

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rest Router for WordPress

Installation

$ composer require uwebpro/wp-rest-router

Usage

use UWebPro\WordPress\Rest\Router;

require_once 'vendor/autoload.php';

$router = new Router('namespace');

//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;
});