Download the PHP package marco476/routing-manager without Composer
On this page you can find all versions of the php package marco476/routing-manager. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download marco476/routing-manager
More information about marco476/routing-manager
Files in marco476/routing-manager
Package routing-manager
Short Description PHP performance-oriented routing manager
License MIT
Informations about the package routing-manager
PHP performance-oriented Routing manager
This library is PHP performance-oriented routing manager working with routes setted by:
- PHP Array
- YAML file
- XML file
Installation
You can install it with Composer:
Usage
Use the routing-manager library is extreme simple. All routes setted must include an expression key/tag for matching with URI.
When you call matchRoute method, the library find a match between routes setted and URI present. It return the route matched array if math with URI is Ok or false if not.
Array
See an example with array:
YML
See an example with YML:
And see a YML routes configuration file:
Note: If you want use a YAML file routes configuration, you must install the yaml php extension. You can install it with sudo apt-get install php-yaml or with PECL. For detail, see that
XML
See an example with XML:
And see a XML routes configuration file:
Note: If you want use a XML file routes configuration, you must install the libxml php extension. You can see that
Wildcards
A wildcard is a jolly name inserting into {} (like {idUser}). You can set wildcards into expression key/tag and set a requirements array key/tag for each one of them (see the example on bottom).
If requirements array is not present for a wildcard, it can be everything. For example:
It can be everything:
- /marco
- /123
- /marco123
If requirements array is present for a wildcard, you can use a custom regular expression or ExpressionRoute static constant for NUMERIC or STRING (only in PHP array) strong expression. For example :
It can be:
- /marco
- /wellName
But not:
- /123
- /marco123
And with custom regular expression:
It can be:
- /marco
- /luigi
and not else! See the examples on bottom:
Wildcards in Array
See an example with array:
Wildcards in YML
See an example with YML:
Wildcards in XML
See an example with XML:
Unit Test
You can run unit test from document root with: