This document provides an overview of Laravel, an open source PHP framework, including its MVC architecture, requirements for installation, and directory structure. It explains that Laravel uses the MVC pattern with models for the backend logic, views for the frontend HTML/CSS, and controllers to connect models and views. It also outlines the steps to install Laravel and create a new Laravel project, and describes the main folders and files in the Laravel directory structure.
4. MVC Architecture
Model : Model deals with backend logical structure
of the application such as data base records. In
laravel it is denoted as Eloquent model.
View : View deals with frontend such as the HTML,
CSS. In laravel it works with Blade Template Engine
and denoted as View.
Controller : Model and View can be communicated
through Controllers. In laravel it is denoted as
Controller.
6. Installing Laravel
Requirements:
The Laravel framework has a few system requirements.
PHP version should be 5.5.9 or greater
Apache or any other compatible web server
Datatabase like MySQL
Composer dependency manager
IDE Tool Such as PHP Storm or Any Editor like
Sublim Text, Notepad++.
7. Installing Laravel
In Linux Apache, MySQL & PHP can be installed
through terminal
$ apt-get install php5-common libapache2-mod-php5
php5-cli php5-mysql php5-curl
8. Installing Laravel
To Check PHP
use php -v at terminal to check PHP version
Or else use localhost to check php information
16. Laravel directory structure
Let us discuss the directory structure in brief
It comes as no surprise that all Laravel projects have
essentially the same directory structure - one in which every
file has its designated place. By gently forcing this directory
structure upon developers, Laravel ensures that your work is
semi-automatically organized the “Laravel way”.
As you can see, this standard directory structure consists of
quite a few subdirectories. This wealth of subdirectories can
be overwhelming at first, but we’ll explore them one by one.
Most of your work will happen in the app/ folder, but here’s a
basic rundown on the function of each of the files and
folders:
17. Laravel directory structure
Top-level Folders and their purpose
/app/Contains the controllers, models, views and
assets for your application. This is where the
majority of the code for your application will live.
You will be spending most of your time in this
folder!
/public/ The only folder seen to the world as-is. This
is the directory that you have to point your web
server to. It contains the bootstrap file index.php
which jump-starts the Laravel framework core. The
public directory can also be used to hold any
publicly accessible static assets such as CSS,
18. Laravel directory structure
/app/Http/routes.php
Suppose routes.php file contains the below
mentioned code
Route::get('/', function()
{
return view('welcome');
});
When you browse
http://localhost/project-name/public/
It goes to routes.php and finds get request and as a
result it goes to return view('welcome'). So it then
20. Laravel directory structure
Suppose routes.php has the below code
Route::resource('photo', 'PhotoController');
It goes to App/Http/Controllers/ directory and finds
PhotoController.php which contains logic for
backend data.
This single route declaration creates multiple routes
to handle a variety of RESTful actions on the photo
resource.
21. Laravel directory structure
Methods or Actions Handled By Resource Controller
Verb Path Action
Route Name
GET /photo index
photo.index
GET /photo/create create
photo.create
POST /photo store photo.store
GET /photo/{photo} show
photo.show
GET /photo/{photo}/editedit photo.edit
22. Laravel directory structure
PhotoController.php
class PhotoController extends Controller
{
public function index()
{
return view('welcome');
}
public function create(){ //logic for create photo }
public function store(){ //logic for store photo }
public function show(){ //logic for show photo}
public function edit(){ //logic for edit photo }