Dynamic Routing
, (*1)
Iāve found that I often times need to have functionality for client/CMS defined routing in my sites, so I put together a quick library that deals with the creation of said routes., (*2)
Usage
You can pull the package in through Composer:, (*3)
{
"require": {
"rupertjeff/dynamic-routing": "dev-master"
}
}
Once the package exists and itās being loaded into your project, create an instance of Rupertjeff\DynamicRouting\Contracts\RouteCreator
. Give that to this package and itāll go from there!, (*4)
// Where $creator is an instance of Rupertjeff\DynamicRouting\Contracts\RouteCreator
DynamicRouter::create($creator)
Laravel 4
If youāre using Laravel 4 (as I do, mostly), you can add the included ServiceProvider and Facade to make things easier for you. Just add, (*5)
'Rupertjeff\DynamicRouting\Laravel\DynamicRoutingServiceProvider'
to your 'providers'
array in ./app/config/app.php
, and, (*6)
'DynamicRouter' => 'Rupertjeff\DynamicRouting\Laravel\Facade'
to your 'aliases'
array. Donāt like the Laravel Facade approach? Grab it off of $this->app['dynamicRouter']
or create your own out of the IoC container., (*7)
Other Projects
Create an implementation of Rupertjeff\DynamicRouting\Contract\Router
and make sure to create a Rupertjeff\DynamicRouting\Router
with that first class as the first parameter to the constructor., (*8)
// Where $router is an instance of Rupertjeff\DynamicRouting\Contract\Router
$dynamicRouter = new Rupertjeff\DynamicRouting\Router($router);
Then just call, (*9)
// Where $creator is an instance of Rupertjeff\DynamicRouting\Contracts\RouteCreator
$dynamicRouter->create($creator);
Thatās it!, (*10)
Contributing
Please send me any issues/pull requests as you find issues, etc. Iām always wanting feedback on my code as well, so mention something if you see it., (*11)
License
This Dynamic Router is open sourced and licensed under the MIT License., (*12)