PHPackages                             lin3s/wp-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. [API Development](/categories/api)
4. /
5. lin3s/wp-routing

ActiveLibrary[API Development](/categories/api)

lin3s/wp-routing
================

Symfony style routing for WordPress

v2.0.1(9y ago)06.7k1[2 issues](https://github.com/LIN3S/WPRouting/issues)1MITPHPPHP ^5.5 || ^7.0

Since Jul 24Pushed 9y ago2 watchersCompare

[ Source](https://github.com/LIN3S/WPRouting)[ Packagist](https://packagist.org/packages/lin3s/wp-routing)[ RSS](/packages/lin3s-wp-routing/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)Dependencies (4)Versions (7)Used By (1)

WP Routing
==========

[](#wp-routing)

> Symfony style routing for WordPress.

[![SensioLabsInsight](https://camo.githubusercontent.com/46c8e332b60940e7845dcc7e9b90da54c2c395fc56135778ac908962bb65ff07/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f66313134343035302d333135662d346333302d613134322d6335373164343261303333342f6d696e692e706e67)](https://insight.sensiolabs.com/projects/f1144050-315f-4c30-a142-c571d42a0334)[![Build Status](https://camo.githubusercontent.com/412bdec172405a6742f47bfe87bd3bd40dd3c3f0cf5fe1a1b9dfe6c1d1e63bb6/68747470733a2f2f7472617669732d63692e6f72672f4c494e33532f5750526f7574696e672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/LIN3S/WPRouting)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b0f0eda56d337f9e5777a0de5ccec3e6dc52054c2b1f378159afa456f0ffbd0c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4c494e33532f5750526f7574696e672f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/LIN3S/WPRouting/?branch=master)[![Total Downloads](https://camo.githubusercontent.com/3e0d0d103b8923c2648bf80e0f53a17123506e7f2b9d0a0009f3a4db5b368c6d/68747470733a2f2f706f7365722e707567782e6f72672f6c696e33732f77702d726f7574696e672f646f776e6c6f616473)](https://packagist.org/packages/lin3s/wp-routing) [![Latest Stable Version](https://camo.githubusercontent.com/b7abea7e4480c45ad288911c2af1858d13e02963881a5dc05364ab350ec79644/68747470733a2f2f706f7365722e707567782e6f72672f6c696e33732f77702d726f7574696e672f762f737461626c652e737667)](https://packagist.org/packages/lin3s/wp-routing)[![Latest Unstable Version](https://camo.githubusercontent.com/af0a9ab72c0820d0d45942858d8855e887570f28b25b4f80daceec7ee4153fdd/68747470733a2f2f706f7365722e707567782e6f72672f6c696e33732f77702d726f7574696e672f762f756e737461626c652e737667)](https://packagist.org/packages/lin3s/wp-routing)

Why?
----

[](#why)

WordPress routing system is a magical awesome but dark system. For non developers this routing just "works" but, when you need to customize it, this process is not very intuitive. In [LIN3S](http://lin3s.com), we are proud PHP developers that like [Symfony](https://symfony.com/) ecosystem so, this library is a simple but powerful approach to **Symfony Routing component** you can easily add to your WordPress project.

If you want to test it, we already have a functional WordPress project that includes this library ready to use, [WordPress Standard Edition](https://github.com/LIN3S/WordpressStandard) :).

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

[](#installation)

The recommended and the most suitable way to install this library is through [Composer](https://getcomposer.org/). Be sure that the tool is installed in your system and execute the following command:

```
$ composer require lin3s/wp-routing

```

Usage
-----

[](#usage)

Before you start using this library we highly recommend getting familiar with [WordPress template hierarchy](https://wphierarchy.com/).

WP-Routing uses [YAML](http://yaml.org/) to match routes with your methods. For example you can write the following in your `routing.yml`:

```
-
  controller: YourTheme\Controller\DefaultController::indexAction
  type: front

-
  controller: WordpressStandard\Controller\DefaultController::notFoundAction
  type: 404

-
  controller: YourTheme\Controller\EventController::searchAction
  type: search

-
  controller: YourTheme\Controller\YourPostTypeController::singleAction
  type: single
  posttype: your-posttype

-
  controller: YourTheme\Controller\PageController::availabilityAction
  type: page
  template: your-template
```

As you can see in the example above you can use the following parameters for each route:

- `controller`: Defines with method will be called when a match for the given route exists.
- `type`: Which type of route will match the current controller. It uses WordPress standard naming conventions and you can check the available ones in [Router](https://github.com/LIN3S/WPRouting/blob/master/src/Router.php) class.
- `template`: Can be used in pages to select a custom template. Internally it uses `get_page_template_slug()` to get the template the page requires. We use our [*template-selector*](https://github.com/LIN3S/WPTemplateSelector) plugin to let the user select the template to be used.
- other parameters: In case you need to target a specific category, post type (archive or single), taxonomy or page you can use extra parameters like slug, id or posttype (see variable names on [WordPress's template hierarchy](https://wphierarchy.com/) page).

To resolve the routes added above just include the following code in your theme's `index.php`:

```
(new \LIN3S\WPRouting\Router())->resolve();
```

> Make sure WPRouting library is autoloaded using [composer's autoload script](https://getcomposer.org/doc/01-basic-usage.md#autoloading)

To Do
-----

[](#to-do)

- Add more specs
- Route registration wih XML
- Route registration wih annotations

Licensing Options
-----------------

[](#licensing-options)

[![License](https://camo.githubusercontent.com/b36972f7d12249f632e8f85192ca596c466cfdbac062a8c7843de413a6d4f30c/68747470733a2f2f706f7365722e707567782e6f72672f6c696e33732f77702d726f7574696e672f6c6963656e73652e737667)](https://github.com/LIN3S/WPRouting/blob/master/LICENSE)

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 78.1% 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 ~76 days

Recently: every ~94 days

Total

6

Last Release

3567d ago

Major Versions

v1.0.3 → v2.0.02016-07-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/b54f0877b7c31df24820fc1c55bd1a4dcda487dbe8ae5b031e6bf8362fecdfe4?d=identicon)[gorkalaucirica](/maintainers/gorkalaucirica)

![](https://www.gravatar.com/avatar/06308bfc15d8774c16d36d727f852c2d29ed8d0d6153637384439747776dc658?d=identicon)[benatespina](/maintainers/benatespina)

---

Top Contributors

[![benatespina](https://avatars.githubusercontent.com/u/3951376?v=4)](https://github.com/benatespina "benatespina (25 commits)")[![gorkalaucirica](https://avatars.githubusercontent.com/u/1749891?v=4)](https://github.com/gorkalaucirica "gorkalaucirica (7 commits)")

---

Tags

symfonywordpressroutinglin3s

###  Code Quality

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[harmbandstra/swagger-ui-bundle

Exposes swagger UI inside your Symfony project through a route (eg. /docs)

42867.3k](/packages/harmbandstra-swagger-ui-bundle)[php-tmdb/symfony

Symfony Bundle for TMDB (The Movie Database) API. Provides easy access to the php-tmdb/api library.

3649.7k](/packages/php-tmdb-symfony)[thecatontheflat/atlassian-connect-bundle

Atlassian Connect Symfony Bundle

357.6k](/packages/thecatontheflat-atlassian-connect-bundle)[onmoon/openapi-server-bundle

Symfony bundle to create a fully-featured API server from an OpenAPI v3 specification

1117.7k](/packages/onmoon-openapi-server-bundle)

PHPackages © 2026

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