Prashant Nigam /
In this chapter we will be creating a simple multi page website to demonstrate the workings of
Laravel’s routing system, without delving into anything too complicated.
As I mentioned in the previous chapter, there are two options available to route web requests
to your code, Controllers and Routes. In this chapter we will be using Controllers since anyone
joining us from other frameworks will be more familiar with them.
3.1 Routing Controllers
So let’s start by taking a look at a Controller :
3 // application/controllers/account.php
4 class Account_Controller extends Base_Controller
7 public function action_index()
9 echo "This is the profile page.";
12 public function action_login()
14 echo "This is the login form.";
17 public function action_logout()
19 echo "This is the logout action.";
A Controller is a PHP Class that represents a section of your website, or web application. Its
Methods or ‘Actions’ represent an individual page, or an end-point of a HTTP request.
In the above example our Account Controller represents our users section of the web site, a
profile page, a login page, and a logout page. Note that the Controller names are appended with
_Controller and that action names are prefixed with action_. Controllers must extend the
Base_Controller, Controller or another Controller class.
Our controller is created in the application/controllers directory as a lower-case file matching
the controller name. The Controller above would be saved at :
Skills LaravelQualifications :-