Refactor Routing and introduce Rewrite component #17

jedrzejchalubek opened this Issue Jan 11, 2017 · 4 comments


None yet

2 participants

jedrzejchalubek commented Jan 11, 2017 edited

Currently router is responsible for registering custom rewrite rules. As there is no way to check if similar rule already exist, this often leads to conflicts with rules already registered by WordPress.

Refactoring process include these steps:

  • Refactor router itself. His task will be only to switch and run correct actions on url match.
  • Routes can be narrowed with Conditional tags with where method.
  • Create new Rewrite component. API around WordPress Rewrite Rules.
  • Create new file where you will be able to register custom rewrite rules (probably src/Http/rewrites.php)
jedrzejchalubek commented Jan 12, 2017 edited

Routing refactoring ready to test with 2b708fa, also documentation roughly updated to reflect new API (

Still needs some additional tweaks, but it's much faster 🚀


Are the conditional tags stripped?

jedrzejchalubek commented Jan 12, 2017 edited

Unfortunately yes (for now). I'm not sure if going to implement they back like they where before, because this was unnatural.

Im thinking about implementing it that way:

Route::get('{name}', function($name) {
    $post = Post::type('post')->find($name);
    'post' => 'post-slug'

On the route matching, items in where statement will be additionally checked. For example route above will call is_single('post-slug') before returning match status.

What do you think about this?


Conditional routes done with 8e3928c and this works pretty neat. Syntax as above, going to update docs :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment