stackoverflow找到的问题:http://stackoverflow.com/questions/23505875/laravel-routeresource-vs-routecontroller
Route::resource('users', 'UsersController');
Verb Path Action Route Name GET /users index users.index GET /users/create create users.create POST /users store users.store GET /users/{user} show users.show GET /users/{user}/edit edit users.edit PUT /users/{user} update users.update DELETE /users/{user} destroy users.destroy
And you would set up your controller something like this (actions = methods)
class UsersController extends BaseController { public function index() {} public function show($id) {} public function store() {} }
You can also choose what actions are included or excluded like this:
Route::resource('users', 'UsersController', [ 'only' => ['index', 'show'] ]); Route::resource('monkeys', 'MonkeysController', [ 'except' => ['edit', 'create'] ]);
https://laravel.com/docs/4.2/controllers#restful-resource-controllers
Implicit controller
An Implicit controller is more flexible. You get routed to your controller methods based on the HTTP request type and name. However, you don't have route names defined for you and it will catch all subfolders for the same route.
Route::controller('users', 'UserController');
Would lead you to set up the controller with a sort of RESTful naming scheme:
class UserController extends BaseController { public function getIndex() { // GET request to index } public function getShow($id) { // get request to 'users/show/{id}' } public function postStore() { // POST request to 'users/store' } }
Implicit Controllers
https://laravel.com/docs/4.2/controllers#implicit-controllers