Download the PHP package windwalker/router without Composer
On this page you can find all versions of the php package windwalker/router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download windwalker/router
More information about windwalker/router
Files in windwalker/router
Package router
Short Description Windwalker Router package
License LGPL-2.0-or-later
Homepage https://github.com/ventoviro/windwalker-router
Informations about the package router
Windwalker Router
Installation via Composer
Add this to the require block in your composer.json
.
Getting Started
Add Routes
Match Route
Add More Options to Route
Route interface: '($name, $pattern[, $variables = array()][, $allowMethods = array()][, $options = array()])'
The printed result:
Build Route
build()
is a method to generate route uri for view template.
Quick Mapping
addMap()
is a simple method to quick add route without complex options.
Rules
Simple Params
Optional Params
Single Optional Params
Matched route could be:
Multiple Optional Params
Matched route could be:
The matched variables will be
Wildcards
Matched:
Matchers
Windwalker Router provides some matchers to use different way to match routes.
Sequential Matcher
Sequential Matcher use the Sequential Search Method to find route. It is the slowest matcher but much more customizable. It is the default matcher of Windwalker Router.
Binary Matcher
Binary Matcher use the Binary Search Algorithm to find route. This matcher is faster than SequentialMatcher but it will break the ordering of your routes. Binary search will re-sort all routes by pattern characters.
Trie Matcher
Trie Matcher use the Trie tree to search route. This matcher is the fastest method of Windwalker Router, but the limit is that it need to use an simpler route pattern which is not as flexible as the other two matchers.
Rules of TrieMatcher
Simple Params
only match when the uri segments all exists. If you want to use optional segments, you must add two or more patterns.
Wildcards
This pattern will convert segments after flower/
this to an array which named tags
:
Single Action Router
Single action router is a simple router that extends Windwalker Router. It just return a string if matched.
This is a single action controller example:
Or a controller with action name:
RestRouter
RestRouter is a simple router extends to SingleActionRouter, it can add some suffix of different methods.
Default Suffix mapping is:
You can override it:
Exception
If Router not matched anything, it throws Windwalker\Router\Exception\RouteNotFoundException
.