PHPackages                             samueltissot/wp\_route - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. samueltissot/wp\_route

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

samueltissot/wp\_route
======================

v0.3.0(7y ago)2017.6k↓20.6%1MITPHPPHP &gt;=7.0

Since Aug 17Pushed 6y ago4 watchersCompare

[ Source](https://github.com/SamuelTissot/WP_Route)[ Packagist](https://packagist.org/packages/samueltissot/wp_route)[ Docs](https://github.com/SamuelTissot/WP_Route)[ RSS](/packages/samueltissot-wp-route/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

WP\_Route
=========

[](#wp_route)

[![CircleCI](https://camo.githubusercontent.com/7bb0d0f5a1f58df3aeda7659aac5df87980291bf3a49d63fbabd580f67cd6833/68747470733a2f2f636972636c6563692e636f6d2f67682f53616d75656c546973736f742f57505f526f7574652f747265652f6d61737465722e7376673f7374796c653d737667)](https://circleci.com/gh/SamuelTissot/WP_Route/tree/master)

This is a fork of [Anthony Budd's](https://github.com/anthonybudd) [WP\_Route](https://github.com/anthonybudd/WP_Route)

### Added features

[](#added-features)

- small security fix
- Named Paths Variable
- renamed parameter to PathVariable
- pass an Request object to the callable function
- option to ignore query string

### basic usage

[](#basic-usage)

```
WP_Route::get('/flights/', 'listFlights');
WP_Route::get('/buses/', 'listBuses');
WP_Route::post('/flights/{flight}/', 'singleFlight');
WP_Route::put('/flights/{flight}/book/{date}', 'bookFlight');
WP_Route::delete('/flights/{flight}/delete', 'deleteFlight');
WP_Route::any('flights/{flight}',   array('Class', 'staticMethod'));
WP_Route::patch('flights/{flight}', array($object, 'method'));
WP_Route::match(['get', 'post'],    'flights/{flight}/confirm', 'confirmFlight');

// if you want to take into account the parameters when doing a path match
WP_Route::get('/flights/', 'listFlights', ["match" => "*"]);

// if you want to match one or more parameters
WP_Route::get('/flights/', 'listFlights', ["match" => ['param2', 'param2', ...]]);

// redirect
WP_Route::redirect('open-google', 'https://google.com', 301);

// close
WP_Route::get('flights/{flight}', function singleFlight(RequestInterface $req) {
    $req->pathVariable('flight');
}
```

#### the arguments list

[](#the-arguments-list)

```
[
    "parameters" => [
        'match' => [[parameter1] [, parameter2 [, ...]]],
        'no_match' => [[parameter1] [, parameter2 [, ...]]],
    ],
]
```

**NOTE:** an empty array means : apply to all

Installation
============

[](#installation)

Require WP\_Route with composer

```
$ composer require samueltissot/wp_route

```

All Callback must accept a variable of type `RequestInterface`
==============================================================

[](#all-callback-must-accept-a-variable-of-type-requestinterface)

a request object is passed to the callable method

**note:** it is in the plans to be able to provide your custom RequestInterface class (PR accepted)

### examples

[](#examples)

```
use samueltissot\WP_Route\RequestInterface;

// an invocable class
class Controller
{
    public function __invoke(RequestInterface $req)
    {
        // code goes here;
    }
}

// or a simple function
function my_super_func(RequestInterface $req) {
    // code goes here;
}

// method inside class

class MyAwesomeClass
{
    public function wow(RequestInterface $req)
    {
        // code goes here;
    }
}
```

The Request Object (RequestInterface)
=====================================

[](#the-request-object-requestinterface)

a small helper object that provide usefull data about the request

### the Interface

[](#the-interface)

```
interface RequestInterface
{
    public function uri();

    public function method();

    public function pathVariables();

    public function pathVariable($name);

    public function parameters();

    public function parameter($name);
}
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity35

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 53.7% 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

Every ~42 days

Total

3

Last Release

2747d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/051f715b14a8aa6c244bf727f157f1b5e38bacb53ce16a5cbcc93dad19cb6027?d=identicon)[SamuelTissot](/maintainers/SamuelTissot)

---

Top Contributors

[![anthonybudd](https://avatars.githubusercontent.com/u/7443012?v=4)](https://github.com/anthonybudd "anthonybudd (29 commits)")[![SamuelTissot](https://avatars.githubusercontent.com/u/11725094?v=4)](https://github.com/SamuelTissot "SamuelTissot (25 commits)")

---

Tags

wordpressrouting

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/samueltissot-wp-route/health.svg)

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

###  Alternatives

[tgmpa/tgm-plugin-activation

TGM Plugin Activation is a PHP library that allows you to easily require or recommend plugins for your WordPress themes (and plugins).

1.8k222.5k13](/packages/tgmpa-tgm-plugin-activation)[aristath/kirki

Extending the WordPress customizer

1.3k73.0k4](/packages/aristath-kirki)[afragen/git-updater

A plugin to automatically update GitHub, Bitbucket, GitLab, or Gitea hosted plugins, themes, and language packs.

3.3k1.6k](/packages/afragen-git-updater)[joanrodas/plubo-routes

WordPress routes made simple.

142.8k](/packages/joanrodas-plubo-routes)[justintadlock/hybrid-carbon

God-like post featured image script.

202.5k](/packages/justintadlock-hybrid-carbon)

PHPackages © 2026

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