WP Manifestindependent plugin directory
manifest / integrations / hc-rest-routes

H+C Rest Routes

Rest API Routes for Wordpress.

★ 0stars
1.5kcomposer installs

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/howatsonco/hc-rest-routes/archive/refs/heads/prod.zip

On Packagist as hc/rest-routes:

composer require hc/rest-routes
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.
Introduction A plugin for custom API routing. Made with love by Howatson+Co. Usage There are two parts to using this plugin: 1. Defining API routes 2. Defining custom controllers for handling response logic To do either of these, you will need to first access the Rest API Server class instance. This can be achieved either by calling the global scope function HCRR like this: Or, by accessing the global scope variable assigned: Defining Routes You can define a route through the registerRoute method attached to the Router class, like so: The registerRoute method takes three arguments: - API URI pattern to be matched for this route to be executed. This can be a regex string. - Name of Controller to instantiate. - Name of method attached to Controller to execute. Defining Controllers When defining Controllers, adhere to the following rules: - The controller must extend \HC\RestRoutes\Abstracts\ControllerAbstract - Controller methods should be named ${name}${httpVerb}, where: - name is the name you pass to the route, and - httpVerb is the HTTP verb of the request (e.g GET, POST, PUT, etc) - Return the data you want to respond with. - Throw a RestfulException provided by the