Update README.md
This commit is contained in:
parent
e3aa113f9e
commit
49ed2107bf
47
README.md
47
README.md
@ -1,12 +1,12 @@
|
||||
# Route
|
||||
|
||||
Minimal PHP Router
|
||||
Minimalistic Web Application 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.
|
||||
Composer needs to know where to locate the package. Add the repository to your project by declaring it in the `composer.json` file.
|
||||
```JSON
|
||||
{
|
||||
"repositories": [
|
||||
@ -24,9 +24,49 @@ Fetch the package by running
|
||||
|
||||
composer install
|
||||
|
||||
## Manual
|
||||
|
||||
Its all in a single file; include it in your project like so
|
||||
|
||||
```PHP
|
||||
require '/change_this/Route.php'
|
||||
```
|
||||
|
||||
# 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`.
|
||||
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.
|
||||
|
||||
@ -34,4 +74,3 @@ With PHP already configured, add this to the server block of your configuration
|
||||
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.
|
Loading…
x
Reference in New Issue
Block a user