3.4 RESTful Controllers
RESTful web applications respond to meaningful HTTP verbs with appropriate data. They are
very useful when building public API’s for your applications.
With Laravel you can have your controller actions respond to individual HTTP verbs using
RESTful controller actions, let’s see this in action.
1 <?php
2
3 // application/controllers/home.php
4 class Home_Controller extends Base_Controller
5 {
6 public $restful = true;
7
8 public function get_index()
9 {
10 //
11 }
12
13 public function post_index()
14 {
15 //
16 }
17
18 }Simply add a boolean public class attribute named $restful and set it to true, then prefix your
actions with the HTTP verb to respond to rather than action_.
Common HTTP verbs are GET, POST, PUT and DELETE.
Anil Bist
Skills Laravel
Qualifications :- High School - SLV, College/University - Graphic Era Deemed Univ University,Location :-Dehradun,Dehradun,Uttarakhand,India
Description:-
I started my Professional Journey in 2006 with one of the Web Development Company in Bangalore and my 1st framework was "Ruby on Rail" as Web development and delivered around 5+ Projects using this platform. Then came another dimension as JEE/Sturst framework, Gradually I realized that I want to build something on my own and give my passion and energy on creating something different a
Explore