Download the PHP package nezamy/route without Composer
On this page you can find all versions of the php package nezamy/route. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package route
Short Description Route - Fast, flexible routing for PHP, enabling you to quickly and easily build RESTful web applications.
License MIT
Homepage https://nezamy.com/route
Informations about the package route
Route v2.0
Route - Fast, flexible routing for PHP, enabling you to quickly and easily build RESTful web applications.
Installation
Or if you looking for ready template for using this route Go to https://github.com/nezamy/just
Route requires PHP 7.4.0 or newer.
Changes list
- Rewrite route based on php 7.4
- Support Swoole extensions
- Support locales to build multi languages website
- Added Auth, Basic, Digest
- Availability to customize route parser and handler
- Smart dependency injection and service container
Usage
Only if using composer create index.php in root.
Create an index.php file with the following contents:
app/routes.php
Use with Swoole
How it works
Routing is done by matching a URL pattern with a callback function.
app/routes.php
The callback can be any object that is callable. So you can use a regular function:
Or a class method:
Method Routing
Parameters
For “unlimited” optional parameters, you can do this:
Regular Expressions
You can validate the args by regular expressions.
Some named regex patterns already registered in routes
Optional parameters
You can specify named parameters that are optional for matching by adding (?)
Groups
Groups with parameters
Locales
Auth
Basic
Digest
Middleware
Global
Middleware on groups
If you make the middleware as a class, you can pass the class with namespace.
the class should be had a handle
method.
Middleware on route
Dependency injection
To learn about Dependency injection and service container please visit this link
Handle and Parser customization
Example of CustomRouteHandler