Download the PHP package szenis/routing without Composer
On this page you can find all versions of the php package szenis/routing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package routing
Simple PHP Router
Updating from version 0.x or 1.x will break your code! read the documentation before upgrading!
Getting started
Step 1 - .htaccess file create an .htaccess file in the root of your project and fill it with the code below:
Step 2 - require szenis/routing
In your terminal execute: composer require szenis/routing
Step 3 - create index.php
Create the file index.php in the root of your project
Step 4 - require autoload.php and use the Router
The following snippet shows how the router can be used.
to your index.php
Optional
For debuging purpose add the following to your index.php
Usage
Wildcard options
The following options exist
- a: (alfabetic chars only)
- n: (numbers only)
- an: (alfanumeric chars only)
- w: (alfanumeric, dash and underscore only)
- ?: (optional parameters) - must be last part of the url
- *: (lazy loading) - must be last part of the url
How to use
Upgrading from v0.x/v1.x to v2.x
- Namespace has changed from
\Szenis
to\Szenis\Routing
$router->setNamespace()
has been removed!- RouteResolver shouldnt be used to resolve routes, use the following instead
$router->resolve($uri, $method);
- Router does not execute the route anymore. From now one it is your responsibility to execute the handler. At the bottom of the section 'Usage' there is an example how to execute the handler.
Changelog
v2.0.0
- Removed 'default' namespace
- Changed namespace from \Szenis to \Szenis\Routing
- Router does not execute the callable itself, this gives you more control over parameter injection
- RouteResolver is callable trough the router
- Bugfix: it is now possible to have more then one parameter in one segment (/{parameter1}-{parameter2}/)
v1.1.0
- Shortcut functions for get, post, put, patch, delete and any
v1.0.0
- Updated readme
- Posible to add default namespace
v0.9.0
- 100% test coverage
- minimum php version reduced from 5.4 to 5.3
v0.8.0
- Added optional parameter
- Added lazy url loading
- Improved code
v0.7.0
- Improved code
v0.6.0
- Changed usages of router check out the
Usages
section for more detail - Posible to add closure to a route
- Routes with query string will be found now (bugfix: v0.6.1)
v0.5.0
- Removed unnecessary code
v0.4.0
- Added interfaces and created an url factory
v0.3.0
- Its now posible to add options to url wildcards for more information see
wildcard options
v0.2.0
- RouteResolver uses regex to match routes quicker