Download the PHP package romeoz/rock-route without Composer
On this page you can find all versions of the php package romeoz/rock-route. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package rock-route
Simple router for PHP
Features
- Filters
- Support REST
- Groups
- Inject arguments to action
- Caching rules
- Standalone module/component for Rock Framework
Table of Contents
- Installation
- Quick Start
- Pattern
- Configurable
- Filters
- Custom filter
- REST
- Using groups
- Route prefixing
- Sub-Domain routing
- Alias for route
- Using response
- Inject arguments
- HMVC
- Local
- Remote
- Caching rules
- Requirements
Installation
From the Command Line:
or in your composer.json:
Quick Start
Pattern
You can use string or array as pattern.
'query' => true
indicates that the URL-param query
was mandatory.
Pattern as string
/items/{id:\d+}/
is equivalent to[ Route::FILTER_PATH => '/items/{id:\d+}/' ]
.
Configurable
Set a rules you can as configurable. Can be useful for using inside your framework.
For groups:
Filters
For using filters you must be installed Rock Filters: composer require romeoz/rock-filters
.
An example of disallow by IP (uses $_SERVER['REMOTE_ADDR']
):
Custom filter (as callable)
Must returns true/false (boolean).
REST
You can specify what actions to use (only
or exclude
):
Also you can specify custom REST scenario:
Using groups
Route prefixing
Here, the 'path' => '/api/'
is the prefix for the rules of this group.
Sub-Domain routing
Alias for route
Using the as
index of our route array you can assign a alias to a route:
Extended example:
Also you can set a alias to group:
All rules belonging to this group will inherit this alias.
For configurable approach you can use the index:
Using response
For using response you must be installed Rock Response: composer require romeoz/rock-response
.
More details see docs
Inject arguments
More flexible use is possible using the library Rock DI: composer require romeoz/rock-di
.
HMVC (Hierarchical model–view–controller)
For using you must be installed Rock Response: composer require romeoz/rock-response
.
Local
Remote
For using you must be installed Guzzle: composer require guzzlehttp/guzzle:6.1.*
.
Required PHP 5.5+
Caching rules
For caching rules/groups you must be installed Rock Cache: composer require romeoz/rock-cache
.
For reset the cache using flushCache()
:
Requirements
- PHP 5.4+
- For using response required Rock Response:
composer require romeoz/rock-response
- For using filters required Rock Filters:
composer require romeoz/rock-filters
- For using Rate Limiter filter required Rock Session:
composer require romeoz/rock-session
- For caching rules required Rock Cache:
composer require romeoz/rock-cache
- For using HMVC remote required Guzzle:
composer require guzzlehttp/guzzle:6.1.*
.
All unbolded dependencies is optional.
License
Router is open-sourced software licensed under the MIT license.
All versions of rock-route with dependencies
romeoz/rock-components Version 0.14.*
romeoz/rock-request Version 0.14.*
romeoz/rock-sanitize Version 0.11.*