DEV Community

AquaCat
AquaCat

Posted on

【Laravel】How to make controller corresponding to REST api

REST is an abbreviation for "REpresentational State Transfer." "REST(ful) api" accesses to a uri of a proper web app by using appropriate HTTP method and url.

For example, to get data of book by specifying book id(3),
you access to 'get/book/3.' 'Get' is a HTTP method and '/book/3' is a url in this case.

In Laravel, you can create controller that corresponds to REST api. Make controller with an option "--resource."

php artisan make:controller XXXController --resource
Enter fullscreen mode Exit fullscreen mode

You will see "index","create","edit","destroy","show","update" methods are already included in the controller.

Top comments (0)