Introduction to Laravel

What is Laravel?

Laravel is PHP framework, which is easy to understand and robust and open source also. It also offer the rich set of functionalities that incorporates the basic features of PHP framework such as Codelgniter, yii, and other programming languages like Ruby on Rails. It is a PHP framework that uses the MVC architecture.

MVC vs NON-MVC:

Let’s first understand the MVC architecture.

MVC stands for Model-View Controller. It is a software design pattern by which creation of huge applications becomes easy. It does not belong to specific programming language or framework, but it is a concept that you can use creating any kind of application or software in any programming language.

Advantages:

Easy to update the application.

Easy for the developers to collaborate and wor together.

East to debug because of multilevel properly written application.

Development becomes fast.

Disadvantages:

MVC architecture is little bit difficult to understand.

Setting up laravel project:

How to set up a Laravel Project

Setting up laravel project is very easy task.

First we need to install composer and xampp in our system. The open command prompt in xampp\htdocs  file.

Install laravel there. The command to install laravel is – composer global require “laravel/installer=~1.1” (NOTE= 1.1 is a larvael version)

After installation of laravel we need to create a project. The command to a  create project is- composer create-project—prefer-dist laravel/laravel blog”5.8.*” (NOTE: blog is name of the project, so we can give any name.)

Understanding the folder structure:

After the laravel project is created, different types of files and folders are created. All the files and folder help us in writing codes

List of folders created:

1.App

2. Bootstrap

3. Config

4.Database

5. Public

6.Resources

7.Routes

8. Storage

9. Tests

10. vendor

1. APP:- The app directory contains the base code of the application.

2. Bootstrap:- The bootstrap directory containd all the app.php files and bootstrapping scripts uded for the application. In this directory there is cache directory which contains framework generated files for performance optimization such as the route and services cache files.

3.Config:- As the name implies, this directory contains all the configuration files.

4. Database:- Database directory contains all the Database files.

5. Public:- In public directory contains the index.php file, which is the entry point for all request entering the application and configures the autoloading. This directory maintains all the other important files like  Javascript, CSS and images. 

6.Resources:- Resources directory contains the views and  un-compiled assets like CSS and JavaScript. It also contains language files, sas files and templetes(if any).

7.Routes:-In routes directory all the laravel routes are defined in routes file. It contain the definition files for routing such as api.php, wed.php etc.

8. Storage:- The storage directory contains file based sessions, file caches, compiled blade templates and many other files which are created by the framework. This is segregated into framework, app and logs directories.

9. Tests:- Test directories holds all the test cases.

10. Vendor:- The vendor directory holds all composer dependency files.

A Quick intro to the Artisian Command line Interface

 Artisian is a command line interface which is  frequently used in laravel and it have set of helpful commands for developing a web application.

Few commands of Artisian:-

  1. php artisian server (To start Laravel project)
  2. php artisian route:cache (To enable caching mechanism)
  3. php artisian list (To view the lit of available commands supported by Artisian)
  4. php artisian help serve (to view help about any command and view the available options and arguments)

A brief description on Laravel

Laravel is a backend web application framework for PHP. It is a robust framework that provides easy development with many essential features. It provides utilities for application deployment and maintenance. It is a great platform for beginners who wants to implement their PHP skills with greater ease as it has a lot of libraries included. The best part is that it is open source and freely available on the net.
Laravel’s 1st version “Laravel 5.1” was released in June 2015. And long term support (LTS) versions are planned to release every two years. Laravel’s latest version is version 8 which was released on Sept 8, 2020.

The best part is that Laravel works on MVC architecture

MVC stands for Model-View-Controller. It is an architectural pattern that separates an application into three main logical components Model, View, and Controller. Each architectural component is built to handle specific development aspects of an application easily.

The control flows in MVC (How MVC works)

Whenever a user requests to view something on the browser, the request is made to the controller. The controller then requests the model to return all the data which is asked for.

If there is a match the model returns the data to the controller and then the controller will instruct the view to display the data.

If there no match or error then the model returns the error to the controller and then the controller will instruct the view to display the error accordingly.

Why Laravel could be the best choice for developers.

Modularity in Laravel helps users with 20 built-in libraries and modules for enhancement of the application and maintaining the code as per the requirements.

Schema Builder is used for maintaining the database schema and related code of PHP. Track of changes is maintained with respect to database migrations.

The blade template engine is used for designing layouts with predefined blocks and hierarchical blocks that include dynamic content. As it is a lightweight template language.

Authentication feature in Laravel eases designing as it includes features such as register, send password reminders, reset forgot password.

E-mail and Queues A mail class in Laravel helps in sending mail with rich content and attachments and also includes features for queuing when users are in large numbers.

Query Builder helps in querying databases using various simple chain methods. It provides ORM (Object Relational Mapper) and ActiveRecord implementation called Eloquent.

Testing is easy in Laravel. It includes features and helpers which help in testing through various test cases. To a better part parallel testing is also possible in Laravel.

Routing helps in scaling and maintaining the code as per the requirements with the help of features and helpers.

The big question in mind Who should work with Laravel?

Laravel provides a great platform to handle PHP codes and maintaining them so, it’s a great platform for beginners to work on.  It’s very fluent, user-friendly, and easy to learn and understand which adds to its advantage making it a better choice for beginners to initiate their work.

Tagged : / / / /