iosley / slim-auto-routes
The middleware for auto load routes to Slim Framework
1.0.1
2015-10-21 00:00 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- slim/slim: 2.*
This package is not auto-updated.
Last update: 2026-04-26 02:33:30 UTC
README
The middleware for auto load routes to Slim Framework
Installation
Using Composer (Recommended)
$ composer require iosley/slim-auto-routes
Usage
Just add your routes path to 'routes.path' in Slim config and add AutoRoutesMiddleware to slim middlerares stack.
Example
<?php
// index.php
$app = new \Slim\Slim();
$yourRoutesPath = 'routes';
$app->config('routes.path',$yourRoutesPath);
$app->add( new \Iosley\Slim\Provider\AutoRoutesMiddleware );
$app->run();
<?php
// routes/index.php
$app = \Slim\Slim::getInstance(); // need this, just if you change the variable name
$app->get('/', function() use ($app) {
echo 'Example of auto load routes to Slim Framework.'
});
License
The code is available at github project under MIT licence.