Download the PHP package gaetanroger/slim-routes-loader without Composer
On this page you can find all versions of the php package gaetanroger/slim-routes-loader. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gaetanroger/slim-routes-loader
More information about gaetanroger/slim-routes-loader
Files in gaetanroger/slim-routes-loader
Package slim-routes-loader
Short Description Register your Slim routes using a simple config file.
License MIT
Informations about the package slim-routes-loader
Slim routes loader
When using Slim PHP Framework, you need to register your routes. This library allows you to do so via a simple config file.
How to install
Using composer is the easiest way.
You can always get the sources from this repo and install it manually in your project.
How to use
For more info about the syntax to follow, see Syntax and rules.
Regular PHP array format
Write your routes using a regular PHP associative array,
then use the Loader
class to import it.
If you want to store your routes in another file, simply include them
using a regular PHP require
.
Json format
If you prefer to write your routes as Json, simply use the JsonLoader
.
The $json
variable can contain a json string or the path to a json file containing
the routes.
Yaml format
If you prefer to write your routes as Yaml, simply use the YmlLoader
.
The $yml
variable can contain a Yaml string or the path to a Yaml file containing
Syntax and rules
No matter what format you choose to use, the loaders require a certain syntax.
Please see the Slim documentation to get more info about specific points.
Route syntax
pattern
: the route patternmethod
: the HTTP method the route is waiting for (GET, POST, etc.)callable
: the function/method/invokable to be called when the route is reachedname
: (optional) the name of the route
Group syntax
pattern
: the group patternroutes
: an array containing other groups or routes
General rules
- The top element must be a group (usually with an empty pattern unless you want to prefix all your routes)
- A pattern can be left empty.