From 88e6143338b59bd3a99f5bf021093add2ae17a7c Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 4 Nov 2011 21:57:40 -0500 Subject: [PATCH] made controllers restful by default. --- application/controllers/home.php | 16 ++++++++++------ laravel/routing/controller.php | 5 ++++- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/application/controllers/home.php b/application/controllers/home.php index c9c3c189..b8afb1ea 100644 --- a/application/controllers/home.php +++ b/application/controllers/home.php @@ -10,31 +10,35 @@ class Home_Controller extends Controller { | Instead of using RESTful routes and anonymous functions, you may wish to | use controllers to organize your application API. You'll love them. | - | To start using this controller, simple remove the default route from the + | To start using this controller, simply remove the default route from the | application "routes.php" file. Laravel is smart enough to find this - | controller and call the default method, which is "index". + | controller and call the default method, which is "get_index". + | + | Just like routes, controllers are also RESTful by default. Each function + | is prefixed with the HTTP verb it responds to, allowing you to quickly + | build beautiful RESTful applications. | | This controller responds to URIs beginning with "home", and it also | serves as the default controller for the application, meaning it | handles requests to the root of the application. | - | You can respond to requests to "/home/profile" like so: + | You can respond to GET requests to "/home/profile" like so: | - | public function profile() + | public function get_profile() | { | return "This is your profile!"; | } | | Any extra segments are passed to the method as parameters: | - | public function profile($id) + | public function get_profile($id) | { | return "This is the profile for user {$id}."; | } | */ - public function index() + public function get_index() { return View::make('home.index'); } diff --git a/laravel/routing/controller.php b/laravel/routing/controller.php index dc99c713..5b8222eb 100644 --- a/laravel/routing/controller.php +++ b/laravel/routing/controller.php @@ -1,6 +1,7 @@