Package Data | |
---|---|
Maintainer Username: | unforeseen |
Maintainer Contact: | rob@robmccann.co.uk (Rob McCann) |
Package Create Date: | 2013-05-28 |
Package Last Update: | 2013-05-29 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2023-05-28 15:08:53 |
Package Statistics | |
---|---|
Total Downloads: | 38 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 7 |
Total Watchers: | 2 |
Total Forks: | 1 |
Total Open Issues: | 0 |
A base controller for laravel that handles formatting.
composer require "rob-mccann/laravel-restful"
Once you've grabbed the code, you'll need to add the RoutingServiceProvider to the list of providers in app/config/app.php as follows
'providers' => array(
...
'RobMcCann\Restful\RoutingServiceProvider',
),
The concept uses the same principles as laravel's resource routing. Your controller should extend the one in this package. Each action should return an array which will automatically be formatted.
Add the route to app/routes.php:
Route::resource('posts', 'PostsController');
Then add the controller as follows
use RobMcCann\Restful\RestfulController as Controller;
class PostController extends Controller {
public function index() {
return array(
array(
'id' => 1,
'title' => 'Released a RESTful controller',
),
);
}
}
I plan on changing some of the internals and class struture within this package but the implmentation shouldn't be affected.