Is Laravel the best PHP framework?

The Google Trends graph below shows the rapid increase of the PHP Laravel framework over the past 5 years.

Outlined below are some of the reasons that Hand Coded Studio usually opt to use Laravel. Of course, the web language and framework will be adjusted depending on the website project requirements.

Out of the box Laravel comes with a routing system, unit testing framework, database query builder, caching, sessions, authentication, middleware and a templating engine called Blade.

Laravel also has an active and growing community that can provide quick support. Laracasts provides training videos (free and paid) along with a free support forum. This help can prove to be invaluable when you hit a common snag.

Note that the content below was written when Laravel was at version 5.4, released in June 2017.

Rest assured, Laravel is one of the best PHP frameworks available. Thousands of websites and applications have been built using Laravel - or it's light weight brother Lumen.

Laravel routing

Routing can be as simple or as complex as you need it. Laravel routing provides the ability to group routes, create resources for CRUD pages and automatically bind models to the request parameters.

Routes can easily be attached to Controllers, which means your application logic is taken away from the routes file and moved to one of your PHP controllers.

Authentication

Laravel authentication can be setup with one simple command. This then automatically creates the routes, templates and controllers that you'll need. You can then customise the web design to match your theme.

If necessary you can roll your own authentication system, but it's advisable to stick with the built in methods as this ensures you don't introduce any security vulnerabilities. A shared community using one codebase ensures that errors/mistakes are discovered and fixed quickly.

Authentication can be controlled from your routes file to restrict access to certain parts of your website.

Database Migrations

A database is essential to most web applications and some websites. For example, the majority of Content Management Systems will use a backend database to store content. Migration files help produce the database structure and maintain it over time. This allows you to work locally, then roll out your database changes automatically on your production server.

This method ensures that your field names and lengths stay consistent, and that your application doesn't error because of missing columns. If an error does arise with a migration, there's an easy command that allows you to rollback to a previous point.

Blade PHP templating language

Blade provides a clear syntax for writing views. It means you won't have to write opening and closing PHP tags hundreds of times. Instead you can use curly braces and the @ symbol. For example, if statements use @if, @else, and @endif. Variables can be printed using this syntax: {{ $variable }}. Blade will quickly perform and cache the transformation for you.

Not only does it save code, Blade can also use includes to avoid repetition. Variables can even be passed in for ultimate customisation. For complete control and standardisation, Laravel also allows Blade views to be used in email templates.

Third party packages

Laravel is designed to work within the PHP ecosystem. Third party tools and code can be added using composer, and used within models and controllers. Some of Laravel's components can be switched to use a service you prefer. For example, file sessions can be switched for Redis sessions. The default mail sender can be replaced to use Sendgrid or Mandrill.

Customisation is key. Although Laravel provides a framework for your project, it in no way restricts the developer when creating websites, products or web applications.


Explore our other projects