Why Laravel is the best PHP Framework

Posted by Darren |18 Mar 17 | 0 comments

Laravel - The PHP Framework For Web Artisans

- - Taylor Otwell

Why Laravel is the best PHP Framework

My Background with Laravel

Over the past number of years, I have been a walking billboard for Laravel. I have tried many different frameworks for PHP and all have left me needing some more features and capabilities. I came across Laravel when Laravel 3 was pretty new (Released February 22, 2012) and fell in love instantly with how easy it was to get started with it. I am pretty sure that by March 1st I dumped codeigniter completely! I was even more impressed with Laravel when I got my hands on version 4. Here are some of the reasons that I would suggest giving Laravel a try.

Composer

Laravel 4 depends a lot of a number of external packages for its functionality. To do this, it is using Composer as a dependency manager. Why does this matter to you? For starters it makes it extreemly easy to get a new laravel project set up. There is no more downloading a zip file from the web or cloning from github and having to remember the url for it, now all you have to do is run:

composer create-project laravel/laravel your-project-name --prefer-dist

and that will give you a full copy of laravel. Now you may think that this is just as complicated as remembering the url and running a ‘git clone’ I would have to agree with you, however, the next steps are the easy part. After you are done creating the project there are only a few more commands that you need to know

composer install
composer update

The first one, ‘composer install’, sets up the laravel project and downloads all dependencies it requires to run. Down in the Laravel core are external packages, all pulled in with composer during the install, that include:

  • Symfony
  • Whoops
  • Doctrine

It is even just as easy to bring in another package into your laravel application by modifying the composer.json file. The one package that I ALWAYS include in my application during development is Laravel Generator by Jeffrey Way.

The final thing Ill say about the perks of Laravel using composer is that all of Laravel’s core components are individually available on the Illuminate GitHub repository.

Artisan

The command line is a very powerful tool for any developer. With Artisan, Laravel expands into being able to use the command line to run many different tasks. Just by typing `php artisan` in your terminal window, you are opened up to multiple options

...
command
command:make Create a new Artisan command
config
config:publish Publish a package's configuration to the application
controller
controller:make Create a new resourceful controller
db
db:seed Seed the database with records
key
key:generate Set the application key
migrate
migrate:install Create the migration repository
migrate:make Create a new migration file
migrate:refresh Reset and re-run all migrations
migrate:reset Rollback all database migrations
migrate:rollback Rollback the last database migration
...

These are just a few commands that are available. With artisan, you can even begin to make your own command line tools.

Database Migrations & Seeds

One pain point for me when I am developing an application is how to keep my database in sync between my development machines. With Laravel database migrations, it is extreemly easy. After a long day of work, I may have made a lot of changes to the database and, in my option, MySQL Workbench is not a great way to sync databases between my development machines. Enter Migrations. As long as I keep all of my database work in migrations and seeds (a file that populates a database), I can easily migrate the changes into any other development machine I have. The other nice part of these is that I am now able to keep my database under version control.

RESTful Routing

This is by far one of the best things in laravel. If you do not know what REST is, check this tutorial out to get more information. Laravel makes it very nice in the way it uses verbs for its routes. Here is a sample of a route file:

Route::get('dogs',function() { return 'These are the dogs!'; });
Route::get('dogs/{id}', array('uses' => 'DogsController@show'));
// Will trigger the show method in DogsController
Route::post('dogs', array('uses' => 'DogsController@create'));
// Will trigger the create method in DogsController only if posted to
...

These are just a few of the reasons why I have switched to Laravel for all of my applications and why Laravel is the best PHP Framework. There are many others that I would suggest looking at, Eloquent, IoC, Testing (with Codeception), and Blade Templates.

 


Leave a Reply

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

3 + ten =