PHPackages                             lumenpress/routing - 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. lumenpress/routing

ActiveLibrary

lumenpress/routing
==================

v0.1.7(8y ago)8243PHP

Since Sep 29Pushed 8y ago1 watchersCompare

[ Source](https://github.com/lumenpress/routing)[ Packagist](https://packagist.org/packages/lumenpress/routing)[ RSS](/packages/lumenpress-routing/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (6)Versions (9)Used By (0)

WordPress Routing
=================

[](#wordpress-routing)

[![Build Status](https://camo.githubusercontent.com/ef33dd898b8fddc0a35a0b7aae18b8e584c4feb3a63b77ba4a98529f67ad2f87/68747470733a2f2f7472617669732d63692e6f72672f6c756d656e70726573732f726f7574696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/lumenpress/routing) [![Total Downloads](https://camo.githubusercontent.com/111c8a802efc571365affe5e815f2e4ceacb075e7c7cef21f16a82fdd4d3dac7/68747470733a2f2f706f7365722e707567782e6f72672f6c756d656e70726573732f726f7574696e672f646f776e6c6f616473)](https://packagist.org/packages/lumenpress/routing) [![Latest Stable Version](https://camo.githubusercontent.com/78c1d86431ebbb863ccb92fd0fb10b20651f4e4de2ad23c1d3cbe87c6500ee83/68747470733a2f2f706f7365722e707567782e6f72672f6c756d656e70726573732f726f7574696e672f762f737461626c65)](https://packagist.org/packages/lumenpress/routing)

The routing needs to be used with [lumenpress/laravel](https://github.com/lumenpress/laravel) or [lumenpress/lumen](https://github.com/lumenpress/lumen).

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

[](#installation)

```
composer require lumenpress/routing
```

Register the provider in `bootstrap/app.php`:

```
$app->register(LumenPress\Routing\ServiceProvider::class);
```

It should be noted that Laravel must also be registered in the `bootstrap/app.php` file, otherwise it will not work properly.

Usage
-----

[](#usage)

We must first get an instance of the WordPress router.

```
$router = app('wp.router');
```

Or use the router service container as a facade.

```
use LumenPress\Routing\Facades\Route;
```

### Routing

[](#routing)

```
$router->is($condition, $callback);
$router->get($condition, $callback);
$router->post($condition, $callback);
$router->put($condition, $callback);
$router->patch($condition, $callback);
$router->delete($condition, $callback);
$router->options($condition, $callback);

$router->group([
        'middleware' => 'auth',
        'namespace' => 'App\Http\Controllers'
    ], function ($router) {
        //
});
```

As a facade.

```
use LumenPress\Routing\Facades\Route;

Route::is($condition, $callback);
Route::get($condition, $callback);
Route::post($condition, $callback);
Route::put($condition, $callback);
Route::patch($condition, $callback);
Route::delete($condition, $callback);
Route::options($condition, $callback);

Route::group([
        'middleware' => 'auth',
        'namespace' => 'App\Http\Controllers'
    ],function () {
    //
});
```

Conditions
----------

[](#conditions)

**Route Parameters**

```
Route::is(string $condition, $callback);
Route::is([$condition => int|string|array $args], $callback);
```

### template

[](#template)

Query Condition

functiontheme fileis\_page\_template($template)`$template`.phpRoute Condition

- `['template' => string|array $template]`

Callback Arguments

- `LumenPress\Nimble\Models\Post $post`;

```
// register templates
LumenPress\Nimble\Models\Post::registerTemplate([
    'home' => [
        'name' => 'Home Page'
    ],
    'contact' => [
        'name' => 'Contact Us'
    ],
    'about' => [
        'name' => 'Contact Us'
    ],
]);

Route::is(['template' => 'home'], function (\LumenPress\Nimble\Models\Post $post) {});

// Multiple
Route::is(['template' => 'contact', 'about'], $callback);
```

### page

[](#page)

Query Condition

functiontheme fileis\_page()page.phpis\_page($id)page-`$id`.phpis\_page($slug)page-`$slug`.phpRoute Condition

- `page`
- `['page' => int|string|array $page]`

Callback Arguments

- `LumenPress\Nimble\Models\Post $post` `optional`;

```
// page.php
Route::is('page', function (\LumenPress\Nimble\Models\Post $post) {});

// page-2.php
Route::is(['page' => 2], $callback);

// page-sample-page.php
Route::is(['page' => 'sample-page'], $callback);

// page-about.php or page-contact.php
Route::is(['page' => ['about', 'contact']], $callback);

// By path
Route::is(['page' => 'about/company'], $callback);
Route::is(['page' => 'about/staff'], $callback);
```

### single

[](#single)

Query Condition

functiontheme fileis\_single()single.phpis\_singular($posttype)single-`$posttype`.phpis\_singular($posttype) &amp;&amp; is\_single($slug)single-`$posttype`-`$slug`.phpRoute Condition

- `single`
- `['single' => int|string|array $post]`

Callback Arguments

- `LumenPress\Nimble\Models\Post $post` `optional`;

```
// single.php
Route::is('single', function (\LumenPress\Nimble\Models\Post $post) {});

// query by post id
Route::is(['single' => 1], $callback);

// single-book.php
Route::is(['single' => 'book'], $callback);

// single-book.php or single-newspaper.php
Route::is(['single' => ['book', 'newspaper']], $callback);

// single-book-foo.php
// or single-book-bar.php
// or single-newspaper-foo.php
// or single-newspaper-bar.php
$single = [
    // $post_type,  $slug
    ['book',        'foo'],
    ['book',        'bar'],
    ['newspaper',   'foo'],
    ['newspaper',   'bar'],
];
Route::is(['single' => $single], $callback);
```

### singular

[](#singular)

Query Condition

functiontheme fileis\_singular()singular.phpis\_singular($posttype)single-`$posttype`.phpRoute Condition

- `singular`
- `['singular' => string|array $posttype]`

Callback Arguments

- `LumenPress\Nimble\Models\Post $post` `optional`;

```
// singular.php
Route::is('singular', function (\LumenPress\Nimble\Models\Page $post) {});

// single-book.php
Route::is(['singular' => 'book'], $callback);

// single-book.php or single-newspaper.php
Route::is(['singular' => ['newspaper', 'book']], $callback);
```

### attachment

[](#attachment)

Query Condition

functiontheme fileis\_attachment()attachment.phpRoute Condition

- `attachment`

Callback Arguments

- `LumenPress\Nimble\Models\Attachment $attachment` `optional`;

```
// attachment.php
Route::is('attachment', $callback);
```

### embed

[](#embed)

Since 4.5

Query Condition

functiontheme fileis\_embed()embed.phpRoute Condition

- `embed`

Callback Arguments

- `LumenPress\Nimble\Models\Post $post` `optional`;

```
// embed.php
Route::is('embed', function (LumenPress\Nimble\Models\Post $post) {});
```

### archive

[](#archive)

Query Condition

functiontheme fileis\_archive()archive.phpis\_post\_type\_archive($postType)archive-`$postType`.phpRoute Condition

- `archive`
- `['archive' => string|array $postType]`

Callback Arguments

- `string $postType` `optional`;

```
// archive.php
Route::is('archive', $callback);

// archive-book.php
Route::is(['archive' => 'book'], $callback);

// archive-newspaper.php or archive-book.php
Route::is(['archive' => ['newspaper', 'book']], function ($postType) {});
```

### tax

[](#tax)

Query Condition

functiontheme fileis\_tax()taxonomy.phpis\_tax($taxonomy)taxonomy-`$taxonomy`.phpis\_tax($taxonomy, $term)taxonomy-`$taxonomy`-`$term`.phpRoute Condition

- `tax`
- `['tax' => string|array $taxonomy]`
- `['tax' => ...[string|array $taxonomy, int|string|array string|array $term]]`

Callback Arguments

- `LumenPress\Nimble\Models\Taxonomy $taxonomy` `optional`;

```
// taxonomy.php
Route::is('tax', function (\LumenPress\Nimble\Models\Taxonomy $taxonomy) {});

// taxonomy-channel.php
Route::is(['tax' => 'channel'], $callback);

// taxonomy-channel-bbc1.php
Route::is(['tax' => [['channel', 'bbc1']]], $callback);
```

### category

[](#category)

Query Condition

functiontheme fileis\_category()category.phpis\_category($id)category-`$id`.phpis\_category($slug)category-`$slug`.phpRoute Condition

- `category`
- `['category' => string|array $category]`

Callback Arguments

- `LumenPress\Nimble\Models\Category $category` `optional`;

```
// category.php
Route::is('category', function (\LumenPress\Nimble\Models\Category $category) {});

// category-9.php
Route::is(['category' => 9], $callback);

// category-news.php
Route::is(['category' => 'news'], $callback);

// by category name
Route::is(['category' => 'Stinky Cheeses'], $callback);

// by id, slug, name...
Route::is(['category' => [9, 'blue-cheese', 'Stinky Cheeses']], $callback);
```

### tag

[](#tag)

Query Condition

functiontheme fileis\_tag()tag.phpis\_tag($id)tag-`$id`.phpis\_tag($slug)tag-`$slug`.phpRoute Condition

- `tag`
- `['tag' => string|array $tag]`

Callback Arguments

- `LumenPress\Nimble\Models\Tag $tag` `optional`;

```
// tag.php
Route::is('tag', function (\LumenPress\Nimble\Models\Tag $tag) {});

// tag-30.php
Route::is(['tag' => 30], $callback);

// tag-extreme.php
Route::is(['tag' => 'extreme'], $callback);
// tag-mild.php
Route::is(['tag' => 'mild'], $callback);

// by id, slug, name...
Route::is(['tag' => [30, 'mild', 'extreme']], $callback);
```

### author

[](#author)

Query Condition

functiontheme fileis\_author()author.phpis\_author($id)author-`$id`.phpis\_author($nicename)author-`$nicename`.phpRoute Condition

- `author`
- `['author' => int|string|array $author]`

Callback Arguments

- `LumenPress\Nimble\Models\User $author` `optional`;

```
// author.php
Route::is('author', function (\LumenPress\Nimble\Models\User $user) {});

// author-4.php
Route::is(['author' => 4], $callback);

// author-john-jones.php
Route::is(['author' => 'john-jones'], $callback);

// by display name
Route::is(['author' => 'Vivian'], $callback);

// by mixed
Route::is(['author' => [4, 'john-jones', 'Vivian']], $callback);
```

### date

[](#date)

Query Condition

functiontheme fileis\_date()date.phpRoute Condition

- `date`

Callback Arguments

- `$year` `optional`;
- `$month` `optional`;
- `$day` `optional`;

```
// date.php
Route::is('date', function ($year = null, $month = null, $day = null) {});
```

### home

[](#home)

Query Condition

functiontheme fileis\_home()home.phpRoute Condition

- `home`

```
// home.php
Route::is('home', $callback);
```

### front

[](#front)

Query Condition

functiontheme fileis\_front\_page()front\_page.phpRoute Condition

- `front`

```
// front_page.php
Route::is('front', $callback);
```

### search

[](#search)

Query Condition

functiontheme fileis\_search()search.phpRoute Condition

- `search`

```
// search.php
Route::is('search', $callback);
```

### 404

[](#404)

Query Condition

functiontheme fileis\_404()404.phpRoute Condition

- `404`

```
// 404.php
Route::is('404', $callback);
```

Custom Route Condition
----------------------

[](#custom-route-condition)

```
Route::registerCondition('author.role', function ($role) {
    if (! is_author()) {
        return false;
    }

    $author = get_queried_object();

    return $role == $author->roles[0];
});

Route::is(['author.role' => 'administrator'], $callback);
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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

Every ~1 days

Total

8

Last Release

3142d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2993310?v=4)[chenos](/maintainers/chenos)[@chenos](https://github.com/chenos)

---

Top Contributors

[![chenos](https://avatars.githubusercontent.com/u/2993310?v=4)](https://github.com/chenos "chenos (41 commits)")

---

Tags

laravellumenrouterroutingwordpress

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/lumenpress-routing/health.svg)

```
[![Health](https://phpackages.com/badges/lumenpress-routing/health.svg)](https://phpackages.com/packages/lumenpress-routing)
```

PHPackages © 2026

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