有关laravel 4中路线资源的信息

I'm new in Laravel 4 development, can't find enough information about resource method in Route class

Route::resource();

How to use it?

It's a great way to setup API's. It implements RESTful in a clever way. The recourse controller route can catch a request and maps it to a specific method in the controller based on the RESTful state.

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');
});

For example:

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)

A practical example: How do I create a RESTful API in Laravel to use in my BackboneJS app