laravel 4中的路由资源信息


information about route resource in laravel 4

我是Laravel 4开发的新手,无法在Route类中找到足够的resource方法信息

Route::resource();

如何使用?

这是设置API的好方法。它以一种聪明的方式实现了RESTful。资源控制器路由可以捕获请求,并根据RESTful状态将其映射到控制器中的特定方法。

routes.php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
// Route group for API versioning
Route::group(array('prefix' => 'api/v1'), function() {
    Route::resource('posts', 'PostController');
});
例如:

POST = store() (Create a new entry)
DELETE = destroy($id) (Delete an entry)
GET = index() (Get all entries)
GET = show($id) (Get one entry)
PUT = update($id) (Update an entry)

一个实际例子:我如何在Laravel中创建一个RESTful API来使用我的BackboneJS应用程序