Laravel 5.2 different routing types

I'm new to Laravel but learning fast. The documentation about Routing says the following:

Route::get($uri, $callback);
Route::post($uri, $callback);
Route::put($uri, $callback);
Route::patch($uri, $callback);
Route::delete($uri, $callback);
Route::options($uri, $callback);

I can code in PHP and know what POST and GET requests are. And also know how to update and delete records via SQL. But why are there so many Route types, aren't POST and GET enough?

And in which situations should I use the PUT , PATCH , DELETE or OPTIONS route?

Thanks in advance.

Theo


That is because it follows the architecture defined by REST specification. The Laravel documentation explains it a little and also shows a table of which method uses what. But, basically, it is:

  • GET -> retrieve a resource or its collection
  • POST -> create one or many resources
  • PUT -> update a whole resource or many of them
  • PATCH -> update a chunk of one or many resources
  • DELETE -> delete one or many resources (although deleting many is not wise)
  • OPTIONS -> shows the options available for the specified resource
  • 链接地址: http://www.djcxy.com/p/41042.html

    上一篇: 需要帮助将API PUT方法添加到Python脚本

    下一篇: Laravel 5.2不同的路由类型