0.0.1 2014-09-02 13:48 UTC


An extension to the Laravel Router to add an extra method ->rest() which creates RESTful routes similar to Laravel's built in resource.


Add the package to your composer.json and run composer update.

    "require": {
        "cyber-duck/restrouter": "dev-master"

Add the service provider in app/config/app.php:


This will add our route class to the IoC container in place of the default, everything will work as standard with the addition of Route::rest()

Example Usage


$options = ['model' => 'ResourceModel'];
Route::rest('resource-name', 'ResourceController', ['model' => 'Models\Resource']);

This is will register the following routes:

URI Name Action
GET HEAD resource-name resource.index
POST resource-name ResourceController@store
GET HEAD resource-name/{models_resource}/{_path?}
PUT resource-name/{models_resource}/{_path?} resource.replace ResourceController@replace
PATCH resource-name/{models_resource}/{_path?} resource.update ResourceController@update
DELETE resource-name/{models_resource}/{_path?} resource.destroy ResourceController@destroy

{_path} will capture the remainder of the path after matching the first part. The controller is also RESTful if you need to add any additional routes.

Options include model, except and only and work the same as resource()