Minimal PHP Router
Go to file
2024-11-13 20:28:28 +00:00
composer.json Update 'composer.json' 2023-03-23 08:13:57 +00:00
example.php Commit 2024-11-13 18:43:11 +01:00
LICENSE Init 2023-03-21 21:41:02 +01:00
README.md Init 2023-03-21 21:41:02 +01:00
Route.php Hotfixxx 2024-11-13 20:28:28 +00:00

Route

Minimal PHP Router

Installation

Composer

Composer needs to know where to locate the package. Let's 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

Usage

When using a production web server such as Nginx you will have to tell it to rewrite requests that don't point to a local file, such as they can be forwarded to your front controller which in this case is public/index.php.

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;
}

See example.php and add it to your public/index.php file. It will act as the front controller.