Download the PHP package fyre/router without Composer
On this page you can find all versions of the php package fyre/router. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package router
FyreRouter
FyreRouter is a free, open-source URI routing library for PHP.
Table Of Contents
- Installation
- Basic Usage
- Methods
- Routes
- Closure
- Controller
- Redirect
- Middleware
- Substitute Bindings
Installation
Using Composer
In PHP:
Basic Usage
$container
is a Container.$modelRegistry
is a ModelRegistry.$config
is a Config.
The base URI will be resolved from the "App.baseUri" key in the Config.
Autoloading
It is recommended to bind the Router to the Container as a singleton.
Any dependencies will be injected automatically when loading from the Container.
Methods
Clear
Clear all routes and aliases.
Connect
Connect a route.
$path
is a string representing the route path, and can include placeholders (that will be passed to the destination).$destination
can be either a string representing the destination, an array containing the class name and method or a Closure.$options
is an array containing configuration options.as
is a string representing the route alias, and will default to null.middleware
is an array of middleware to be applied to the route, and will default to [].method
is an array of strings representing the matching methods, and will default to [].placeholders
is an array of regular expression placeholders, and will default to [].redirect
is a boolean indicating whether the route is a redirect, and will default to false.
You can generate the following helper methods to connect specific routes.
See the Routes section for supported path and destination formats.
You can also pass additional arguments to the middleware by appending a colon followed by a comma-separated list of arguments to the alias string. You can use route placeholders as arguments by referencing the route placeholder surrounded by curly braces.
Get Base Uri
Get the base uri.
Group
Create a group of routes.
$options
is an array containing the group options.prefix
is a string representing the route group path prefix, and will default to null.as
is a string representing the route group alias prefix, and will default to null.middleware
is an array of middleware to be applied to the route group, and will default to [].placeholders
is an array of regular expression placeholders, and will default to [].
$callback
is a Closure with the Router as the first argument.
Load Route
Load a route.
$request
is a ServerRequest.
This method will return a ServerRequest, with the route
parameter set to the loaded route.
Url
Generate a URL for a named route.
$name
is a string representing the route alias.$arguments
is an array containing the route arguments, where the key is the placeholder name.?
is an array containing route query parameters.#
is a string representing the fragment component of the URI.
$options
is an array containing the route options.fullBase
is a boolean indicating whether to use the full base URI and will default to false.
Routes
All routes extend the Fyre\Router\Route
class, and include the following methods.
Check Method
Check if the route matches a test method.
$method
is a string representing the method to test.
Check Path
Check if the route matches a test path.
$path
is a string representing the path to test.
Get Arguments
Get the route arguments.
Get Binding Fields
Get the route binding fields.
Get Destination
Get the route destination.
Get Middleware
Get the route middleware.
Get Path
Get the route path.
Get Placeholders
Get the route placeholders.
Handle
Handle the route.
$request
is a ServerRequest.$response
is a ClientResponse.
This method will return a ClientResponse.
Set Middleware
Set the route middleware.
$middleware
is an array containing the route middleware.
Set Placeholder
Set a route placeholder.
$placeholder
is a string representing the route placeholder.$regex
is a string representing the placeholder regular expression.
Closure
$container
is a Container.$destination
is a Closure.$path
is a string representing the route path, and will default to "".$options
is an array containing route options.middleware
is an array of middleware to be applied to the route, and will default to [].method
is an array of strings representing the matching methods, and will default to [].placeholders
is an array of regular expression placeholders, and will default to [].
The $path
and $destination
can be expressed in the following formats:
Route parameter entity binding is handled by the Substitute Bindings middleware.
Controller
$container
is a Container.$destination
is an array containing the controller class name and method.$path
is a string representing the route path, and will default to "".$options
is an array containing route options.middleware
is an array of middleware to be applied to the route, and will default to [].method
is an array of strings representing the matching methods, and will default to [].placeholders
is an array of regular expression placeholders, and will default to [].
The $path
and $destination
can be expressed in the following formats:
Route parameter entity binding is handled by the Substitute Bindings middleware.
Get Action
Get the route controller action.
Get Controller
Get the route controller class name.
Redirect
$container
is a Container.$destination
is a string representing the destination.$path
is a string representing the route path, and will default to "".$options
is an array containing route options.middleware
is an array of middleware to be applied to the route, and will default to [].method
is an array of strings representing the matching methods, and will default to [].placeholders
is an array of regular expression placeholders, and will default to [].
The $path
and $destination
can be expressed in the following formats:
Middleware
$container
is a Container.$middlewareRegistry
is a MiddlewareRegistry.$router
is a Router.
Any dependencies will be injected automatically when loading from the Container.
Handle
Handle a ServerRequest.
$request
is a ServerRequest.$next
is a Closure.
This method will return a ClientResponse.
Substitute Bindings
This middleware will automatically resolve entities from route placeholders based on the parameter types of the route destination.
$container
is a Container.$middlewareRegistry
is a MiddlewareRegistry.$entityLocator
is an EntityLocator.
Any dependencies will be injected automatically when loading from the Container.
Handle
Handle a ServerRequest.
$request
is a ServerRequest.$next
is a Closure.
This method will return a ClientResponse.
All versions of router with dependencies
fyre/error Version ^6.0
fyre/middleware Version ^6.0
fyre/orm Version ^11.0
fyre/server Version ^4.0
fyre/uri Version ^3.0