What is Laravel?

Laravel is a free, open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications following the MVC architectural pattern.

Personally speaking, I have been developing websites using PHP for past 3 years. After meeting with Laravel, I can’t think of writing raw PHP codes rather than using Laravel. The most significant feature of it to me is maintainability and writing less codes.

Popularity of Laravel

Although Laravel is a relatively new PHP framework (it was released in 2011), according to Sitepoint’s recent online survey, it is the most popular framework among developers.
Laravel Popularity

Why should I use Laravel?

There are many PHP frameworks out there and Laravel is one of them. If you never used any frameworks, then it’s high time that you should learn it. And if you used any other frameworks than Laravel, try to get to know it and you may fall in love with it. It is for me the best framework to build any kind of web app with PHP. Here are some reasons why you should use it:

Authentication is the most important part of any web application and developers spent huge amount of time writing those authentication codes. But with Laravel, you can create authentication system in less than a minute.

This is how I make authentication system in Laravel.

php artisan make:auth

That’s it. It will create everything including views, controllers, models and any other things that are needed.

MVC Architecture
Speaking of models, views and controllers, Laravel actually follows MVC architectural pattern. That means views, models and controllers are absolutely separate from each other.

Now you if never knew MVC, you may think why I should use MVC architecture. Let me give you a case scenario. Suppose, you are writing a web app using raw PHP and which is obviously not MVC. And now you are writing codes for authentication for your web app. So your code will be huge!

It will contain html codes for forms and buttons and it will also contain PHP codes and SQL queries. And also, it will contain logic for form validation. This type of code is hard readable. If you open this code after 3/4 months, you yourself will not be able to find out what are in these. But with MVC, the view will only contain the HTML. For database table, you have your model and for inserting records and validations, you have controllers. It can’t be more simple.

Easier SQL Queries
Suppose, you want to get a list of users. In PHP, you write it like this:

$sql = mysql_query("Select * from user where id='".$_SESSION['userID']."'");
$userRow = mysql_fetch_array($sql);

But in Laravel, we do it like this:

$users = User::all();

It’s that simple!

Automatic Pagination
The paginate method provided by Laravel automatically takes care of setting the proper limit and offset based on the current page being viewed by the user. Considering the above example, f we want to see 10 users per page, we can write like this:

$users = User::paginate(10);

Easier Form Validation
Form validation is much easier in Laravel. You don’t have to write lines of lines of if-else conditions to validate the form. Here’s an example of a form validation of user registration in Laravel:

$this->validate($request, [
	        'name' => 'required|max:255',
            'address' => 'required|min:2',

Pretty URLs
Pretty URL is very helpful for SEO purpose. Not only it’s important for SEO, but also it makes the url more readable and most importantly meaningful to the users. Now if you are using raw PHP, you already know the pain that you have to go through if you want to implement pretty URLs to your site.

Thanks to Laravel, all the URLs are already pretty!

Master Layout
I bet you have been writing

<?php include 'header.php'; ?>


<?php include 'footer.php'; ?>

at the beginning and ending in each of your pages. In Laravel, you can create a master layout file where you can define headers, footers, sidebars and anything that you need. And in rest of the pages, you can just write the contents! Isn’t that amazing?

SQL Injections
I’m sure you have heard of it before. This is what hackers do to hack a site. Laravel’s Eloquent ORM uses PDO parameter binding in order to avoid SQL injection. In another word, Laravel is secure!

Cross-Site Request Forgery
Imagine a situation, in which a malicious third-party crafts a special link which when clicked, initiates a request to another site where you are registered and happen to be authenticated into (by way of a session cookie). Suppose, this link’s endpoint performed a sensitive task such as updating your profile to include a spam message. Because you are authenticated, the site will presume the request is indeed coming from you, and update the profile accordingly.

CSRF (cross-site request forgery) tokens are used to ensure that third-parties cannot initiate such a request. This is done by generating a token that must be passed along with the form contents. This token will then be compared with a value additionally saved to the user session. If it matches, the request is deemed valid, otherwise it is deemed invalid.

If you are constructing forms using standard HTML (which I do not recommend), then you will need to supply the token to your form like so:

<form ...>
{!! csrf_field() !!}

Multilingual Support
Laravel comes with the support of multilingual system. You can easily translate your web app to multiple languages.

View Composers
The view composer is one of the most important features of Laravel which makes sure that the controllers load a bunch of data from models for views which is not related to that method’s page content.

Unit Testing
Laravel enables its web artisans to test their code in the best way possible. Using the Artisan command line utility, developers can write their own multiple unit tests easily.

Great Community & Documentation
Last but certainly not least reason to use Laravel, it has a great community, a really cool documentation website Laravel.com and the best video tutorials out there laracasts.com by Jeffrey Way.


In terms of code re-usability and simplicity, Laravel is one of the best PHP Frameworks out there and it is getting popular to the developers day by day. It can save your time by writing less codes. If you want to learn Laravel, there are many tutorials on our site that you can check out!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>