PHPackages                             latomate07/wp-rest-route-creator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. latomate07/wp-rest-route-creator

ActiveLibrary[API Development](/categories/api)

latomate07/wp-rest-route-creator
================================

v1.0.0(2y ago)1161MITPHP

Since Mar 24Pushed 2y ago1 watchersCompare

[ Source](https://github.com/latomate07/WP-RestRouteCreator)[ Packagist](https://packagist.org/packages/latomate07/wp-rest-route-creator)[ RSS](/packages/latomate07-wp-rest-route-creator/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

WP Rest Route Creator
=====================

[](#wp-rest-route-creator)

A simple and elegant way to add custom routes to your WordPress REST API for plugin and theme developers.

Features
--------

[](#features)

- Easy-to-use and reusable system for adding custom routes.
- Middleware support for filtering and modifying requests before they reach their destination.
- Group routes with specific middlewares.
- Built-in preset middlewares for common use cases.

Installation
------------

[](#installation)

Install the package using Composer:

```
composer require latomate07/wp-rest-route-creator
```

Usage
-----

[](#usage)

Here's a basic example of using the `ApiRoute` class to register custom routes:

```
use Latomate07\WpRestRouteCreator\ApiRoute;

ApiRoute::get('/example', function (WP_REST_Request $request) {
    return new WP_REST_Response(['message' => 'Hello, World!'], 200);
});

ApiRoute::post('/example', function (WP_REST_Request $request) {
    return new WP_REST_Response(['message' => 'Data received: ' . print_r($request->get_params(), true)], 200);
});
```

### Middleware

[](#middleware)

You can add middleware to your routes for filtering and modifying requests. Here's an example using the built-in `IsUserAuthenticated` middleware:

```
use Latomate07\WpRestRouteCreator\ApiRoute;
use Latomate07\WpRestRouteCreator\Middleware\IsUserAuthenticated;

ApiRoute::get('/example')
    ->middleware([new IsUserAuthenticated()]);
```

You can chain multiple middleware:

```
use Latomate07\WpRestRouteCreator\Middleware\RateLimiter;
use Latomate07\WpRestRouteCreator\Middleware\Cors;

ApiRoute::get('/example')
    ->middleware([
        new IsUserAuthenticated(),
        new RateLimiter(10),
        new Cors(),
    ]);
```

#### Built-in Middleware

[](#built-in-middleware)

The package includes several built-in middleware for common use cases:

- `IsUserAuthenticated`: Checks if the user is authenticated.
- `RateLimiter`: Limits the number of requests per minute.
- `Cors`: Adds Cross-Origin Resource Sharing (CORS) headers to the response.
- `ApiKeyAuthentication`: Authenticates requests using an API key.

#### Custom Middleware

[](#custom-middleware)

You can create your own custom middleware by creating a new class with a `handle` method:

```
namespace MyPlugin\Middleware;

use WP_REST_Request;
use WP_REST_Response;

class MyCustomMiddleware
{
    public function handle(WP_REST_Request $request)
    {
        // Perform your custom logic here.

        return $request;
    }
}
```

To use your custom middleware, add it to your routes:

```
use Latomate07\WpRestRouteCreator\ApiRoute;
use MyPlugin\Middleware\MyCustomMiddleware;

ApiRoute::get('/example')
    ->middleware([new MyCustomMiddleware()]);
```

### Route Groups

[](#route-groups)

You can group routes and apply middleware to all routes within the group:

```
use Latomate07\WpRestRouteCreator\ApiRoute;
use Latomate07\WpRestRouteCreator\Middleware\IsUserAuthenticated;

ApiRoute::group(function () {
    ApiRoute::addMiddleware(new IsUserAuthenticated());

    ApiRoute::get('/forms', [FormController::class, 'index']);
    ApiRoute::post('/forms', [FormController::class, 'store']);
});
```

In this example, the `IsUserAuthenticated` middleware is applied to all routes within the group.

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit a pull request with your proposed changes.

License
-------

[](#license)

WP Rest Route Creator is released under the MIT License. See the [LICENSE](LICENSE) file for more information.

Support
-------

[](#support)

If you have any questions or need help, please open an issue on GitHub.

---

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

833d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/65642962?v=4)[Tahirou Magagi](/maintainers/latomate07)[@latomate07](https://github.com/latomate07)

---

Top Contributors

[![latomate07](https://avatars.githubusercontent.com/u/65642962?v=4)](https://github.com/latomate07 "latomate07 (6 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/latomate07-wp-rest-route-creator/health.svg)

```
[![Health](https://phpackages.com/badges/latomate07-wp-rest-route-creator/health.svg)](https://phpackages.com/packages/latomate07-wp-rest-route-creator)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M20](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172445.0k16](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
