Getting Started With Laravel Framework

Prerequisites

Installing Laravel Framework

We need to download and install Laravel through Composer command in Terminal / Console, to do that type-in the following command.

λ composer global require "laravel/installer=~1.1"

Once installed, laravel new command will create a fresh Laravel Installation in the current directory. Let's create one new project by utilizing laravel CLI.

λ laravel new my-app

Next, change your current directory to the root folder of the project.

λ cd my-app

To start the Laravel Server, type the following command in your Terminal / Console.

λ php artisan serve

You will be able to visit your application on http://127.0.0.1:8000

folder Structure

App > app folder is the main application folder which includes Console, Http, Providers and Models.

  • Http > this folder contains Controllers, Middleware, Resources
  • Providers > this contains Service Provider files which are required to register various events for core service and application.

Database > this directory includes various parameters for database functionalities.

  • migrations > contains database migration files.
  • seeds > contains class for unit testing
  • factories > used to generate large number of data records.

Public > Laravel uses this folder to initialize the application.

  • .htaccess > contains Server Configurations.
  • CSS > for static css files serving.
  • JS > for static javascripts file serving.

Resources > this directory includes View and assets for your application.

  • assets > useful for LESS and SCSS file serving.
  • lang > this folder includes configuration for localization.
  • views > contains blade template for Laravel.

Routes >  contain web.php, api.php, console.php and channels.php files.

  • web.php > this file contains all the web routes for the application.
  • api.php > this is used to register api routes for the application.

Storage > this folder contains framework session storage and logs data.

Vendor > vendor contains all the development dependencies required for Laravel.

.env > environment file contains all the environment variables required by the application. You can define your own variable here, which can be accessed through whole application.

Model-View-Controller (M.V.C) Architecture

M.V.C – is an architectural design in pattern that separates a Laravel application into three main logical components –

  • Model
  • View
  • Controller

Model > Model components have all the data related logic and business logic of the application.

View > View holds all the User Interface logic of the application. We can retrieve and show the data to the user using View.

Controller > Controller acts as an interface between Model and View Components to process all the business logic and incoming requests.