PHP Frameworks Comparison Series: Laravel

development_13_1

As part of Artemis Consulting’s PHP Frameworks Comparison Series, today we explore the PHP framework Laravel. In 2011, Taylor Otwell introduced a new MVC framework called Laravel. Within 4 years, Laravel became the one of the most popular PHP frameworks (if not the most popular) in the world. But what was the secret behind this success?

Keys to Laravel’s success:

  1. Great documentation
  2. Simple file structure that made it easy to learn
  3. Expressive syntax
  4. Inversion of control (IoC) container- a tool to manage dependency injection
  5. Easy routing and configuration

As part of our frameworks comparison, we looked at the evaluation criteria defined in PHP Frameworks Comparison 2015 – Evaluation Criteria. We evaluated the following criteria on Laravel, and these are our results:

Core Framework design:

  1. MVC support
    Laravel is based on the MVC design pattern, it separates Models from Views and the work is orchestrated through Controllers.
  2. Creating thin controllers
    Laravel allows for the creation of thin controller methods and does all the required actions outside the controller using services and helpers.
  3. Exception handling at framework level
    Laravel comes with a default error handler which catches all errors from the framework, but a developer can extend this functionality in the way he/she wants.
  4. Inheritable configuration with respect to environments and installation across servers
    Laravel’s configuration file makes it very easy to set up different settings for different environments.
  5. Overhead required to create basic module configuration
    Minimal. It is straightforward to configure a new module.
  6. PHP 5.5+ support
    Supported.
  7. Event management framework
    The Laravel Event class provides a simple Observer implementation which allows it to subscribe and listen to the events.
  8. Dependency injection support
    Laravel supports dependency injection through the Inversion of control (IoC) container.
  9. Ease of bootstrapping and integrating with PHPUnit
    Laravel includes PHPUnit as part of a fresh installation. phpunit.xml is available. It is easy to create a test class by extending the TestCase class and running phpunit on the command line.
  10. UI templating support
    Blade is a simple, yet powerful templating engine provided with Laravel. Blade is driven by template inheritance and sections. Blade is close to Twig in terms of implementation.
  11. Command Line Interface (CLI) to execute applications
    Artisan is the name of CLI included in Laravel. It’s very powerful in allowing developers to create new command line programs.
  12. Support for manipulation of various data formats like JSON and XML
    Supporting JSON as I/O is available by the core framework but XML is handled by a third party module.
  13. Useful debugging tools – such as logger support with customizable log levels, DB call instrumentation and request parameter logging.
    For debugging, Laravel uses monolog which is a powerful logging tool and saves the logs into a single file. Laravel also automatically logs all database calls made in memory.

Performance, scalability and redundancy

  1. Support for application caching
    Laravel supports Memcached and Redis
  2. Special features or capabilities focused on performance
    Artisan, the command line interface included with Laravel, has a tool to optimize classes.
  3. Proven adoption on large projects
    We could not find any large projects that are currently using Laravel, but Laravel is widely used to build smaller websites for many small and medium businesses.

Security

  1. Modules for security such as authentication and authorization, and granular access controls
    There are many security modules that are part of Laravel such as auth, modules that store hashed passwords, modules for authenticating users, and modules for CSRF protection.
  2. Frequent security patching
    Laravel’s GitHub repo is updated periodically with over 55 releases to-date and about 300 contributors as of August 2015. Some of these are security-related patches.

Instrumentation and troubleshooting support

  1. Instrumentation metrics or accessibility at the method level
    This is supported by third party applications (Laravel Debugbar)
  2. Instrumentation metrics or accessibility at the SQL level
    This is supported by third party applications (Laravel Debugbar)

Database and Object-Relational-Mapping (ORM) support

  1. Support for models that interact with relational databases used at the client, specifically MySQL and Oracle, and possibly MariaDB in the future
    Laravel includes simple ORM support using Eloquent which is an ActiveRecord ORM, and supports MySQL and MariaDB. A third party ORM application is needed for Oracle.
  2. Support for fine tuning of the SQL used in the ORM
    Yes, this is supported by the query builder
  3. Support for interaction with NoSQL databases like MongoDB
    This is possible by third party libraries such as Laravel MongoDB and Mandango

Community Support

  1. Active maintenance and periodic releases
    Laravel is actively maintained, updated, and has released multiple new versions with about 300 contributors to its GitHub project
  2. Large developer community, support and discussion forums
    Since it is the most popularly used PHP framework at this time, it enjoys a large developer communities and active forums.
  3. Ability to run on a wide variety of Linux and Unix platforms such as RedHat, CentOS, Ubuntu, and MacOS
    Since it is a PHP framework, it can run on all supported operating systems
  4. Well documented – up-to-date with current release
    Great documentation for each release, making it easy to learn.

In addition to the features that we evaluated above, there are more features available in Laravel such as installation support with composer. Development with Laravel is easy. Laravel makes it easier to maintain code, and configure web applications for different environments than many other frameworks. The developer communities and forums to get help from other developers have grown over time providing a rich knowledge base for any new adopters.

In the next few weeks, we will be exploring some other popular PHP frameworks and evaluating them with the criteria defined in PHP Frameworks Comparison 2015 – Evaluation Criteria.