DEV Community

AquaCat
AquaCat

Posted on

1 1

【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)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay