Download the PHP package kiryi/routyi without Composer
On this page you can find all versions of the php package kiryi/routyi. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Package routyi
Short Description Routing mechanism for web applications.
License GPL-3.0-or-later
Homepage https://kiryi.net/
Informations about the package routyi
Kiryi's ROUTYI
A routing mechanism for web applications.
Installation
Usage
First set up the routing table. Then use:
All endpoint classes have to implement the Kiryi\Routyi\EndpointInterface
and so must have a method run(array $params)
.
Constructor Definition
Parameters
namespace
Optional namespace your routing table endpoints start with. If no namespace is provided, endpoints have to be configured with their fully qualified namespace in routing table.
routingTableFilepath
Optional filepath to the routing table INI file. It is relative to your project's root directory. If no filepath is provided, default (config/routing.ini) is used (more information).
configFilepath
Optional filepath to a configuration INI file. It is relative to your project's root directory. If no filepath is provided, default (config/routyi.ini) is used. This filepath is only relevant if you are using a subdirectory (more information).
Method Definition route
The Routing Table
The routing table is an INI file consisting of routes (key) and corresponding endpoints (value). The default filepath is config/routing.ini. If you want to change this, see constructor parameter string $rountingTableFilepath
.
Basic Structure
The single slash '/' is the default controller. It is used as home page and everytime no actual route is found.
If you want to configure a namespace for the endpoints, see constructor parameter string $namespace
and the provided example.
Routes Parameters
The URL will be processed from the longest possible route to the shortest. As soon as a route from the routing table matches, everything after the route part is considered parameters and gets put into an array, which is passed to the run
method.
Using a Subdirectory
If you are using a subdirectory for your web application, you have to specify a configuration INI file with the following content:
The default filepath is config/routyi.ini. If you want to change this, see constructor parameter string $configFilepath
.
Example
configuration/routes.ini
src/Bootstrap.php
URL mydomain.com will route to MyProject\Controller\HomeController
.
URL mydomain.com/about will route to MyProject\Controller\AboutController
.
URL mydomain.com/wrong/route will route to MyProject\Controller\HomeController
. Since /wrong/route is not a matching route, the part is interpreted as parameters and passed to the run
method of the HomeController
.