1.5 KiB
1.5 KiB
Route
Minimalistic Web Application Router
Installation
Composer
Composer needs to know where to locate the package. Add the repository to your project by declaring it in the composer.json
file.
{
"repositories": [
{
"type": "vcs",
"url": "https://git.willy.club/WillySoft/Route"
}
],
"require": {
"willysoft/route": "dev-master"
}
}
Fetch the package by running
composer install
Manual
Its all in a single file; include it in your project like so
require '/change_this/Route.php'
Usage
See example.php
Access directly
The simplest way to access your routes. Put your file in the folder you like and it will automatically account for it.
Examples
ENTRYPOINT = /index.php
/index.php -> /
/index.php/ -> /
/ -> /
/index.php/somepath -> /somepath
ENTRYPOINT = /your_root/index.php
/your_root/index.php -> /
/your_root/index.php/ -> /
/your_root/ -> /
/your_root/index.php/somepath -> /somepath
Rewrite requests
The more sexy way of doing it. Suitable for production.
ENTRYPOINT = /index.php
/ -> /
/somepath -> /somepath
NGINX
With PHP already configured, add this to the server block of your configuration to make requests that don't match a file on your server to be sent to your front controller and begin routing.
location / {
try_files $uri $uri/ /index.php?$query_string;
}