Add new comment

Yii2 vs Laravel 5 - Rapid Application Development in PHP

By Daniel
- Updated 7 years ago
5 comments

Some background

I used to be professional web developer before dedicating myself to Environmental Engineering. Nowadays I only develop applications for very specific engineering and scientific purposes. Since I have an average of one project per year, I can give myself the time to research and learn about the recent platforms and best practices for those projects.


My experience with PHP applications development started before the year 2000. At that time, we had a very limited set of functions in the PHP core and the discussions in the Forums were around the best ways to authenticate a user, store cookies and save passwords in databases. A lot happened in the last 15 years, programmers realized that most of their applications looked the same in terms of coding and started to provide functional plug-and-play libraries known as modules. PHP modules were then combined with theories of application organization (aka "MVC") and the "Frameworks" emerged.


Since frameworks are quite recent and most of the PHP programmers were already used to do the things in their own way, many decided to create their own platform based in their own personal beliefs. This combined with social networks activism lead us to the "Best PHP Frameworks in the World" nightmare.


Living in this nightmare I had the chance to develop applications using CodeIgniter (1.x), CakePHP, Laravel and Yii. This article represents my opinion between the two "trendy" frameworks for the specific scope below. It took me about 3 months to deeply understand their weakness and strengths and this article was focused in how they could help me to get my objective applications done quickly.

What my PHP web applications normally do

  • Standard straightforward user interface with a frontend and a backend. No fancy HTML designs here.
  • Authenticate the users and enable features according to the groups/roles they belong.
  • Allow the users to browse, add, edit and delete data from a database (CRUD).
  • Generate some user customizable reports.
  • Generate some customizable graphics based in the stored data.
  • Export/Import data to Excel spreadsheets and/or CSV tables.
  • Display non-editable/read-only contents in the frontend.
  • Get and process data from very specific external sources using third party APIs.

What I expect from a PHP Framework

  • Login and permissions/roles system out from the box compatible with the best security practices.
  • Rapid prototyping: Automatic generation of the boilerplate for CRUD (Create Read Update and Delete) operations from an existing table or database schema.
  • Rapid prototyping: Automatic generation of Forms and Views for the CRUD operations. I will later customize this code but I need something to check if my models and controller logic are OK before going deeper.
  • Plug and Play AJAX based CRUD operations (REST, RESTFUL...) that could be used with client side JavaScript interfaces.
  • Some logging for user actions and system errors.
  • Some statistics.
  • Helpers for: dropdown lists, search boxes, pagination, table ordering, printing and data exportation.
  • Some basic CSS and Javascript code for the boilerplate pages (I don't like Bootstrap look but that's nice for the beginning).
  • Minimum external packages dependency for the operations above.
  • Option to NOT USE super automated dependency repositories and build tools (Composer, Bower, NPM, Grunt, etc...).

Laravel 5

Strenghts

  • Concise core system with well written and very intuitive components.
  • Many activists all around the internet.
  • Uses proven components from very traditional frameworks (ex. Symphony).
  • Latest PHP programming practices and versions are always incorporated in new versions.
  • Excellent performance (without 3rd party extensions).
  • Native cloud/file handling modules.

Weakness

  • No continuity between versions. Update the core for the version 4 to the version 5 and your application will break.
  • Artisan auto-generators are too basic. You will get much faster results by coping and pasting existing code from other projects since the make commands only build skeletons.
  • No standard/development views generation. You will spend hours coding before being able to test your application outputs.
  • No authorization/ACL/roles features included in the official distribution (what is authentication without hierarchy?).
  • Default authentication system is incomplete and requires manual implementation of basic features.
  • No HTML or form helpers in the official distribution. All HTML and the respective PHP backend coding must be done manually
  • Most of the extension packages available don't make use of native Laravel components. The result is an application with a lot of code redundancy. In fact, most of the extensions are framework agnostic pieces of software that could work wherever you want.
  • Most of the extensions lack documentation and won't run out of the box. You'll find yourself reading a dozen times the GitHub's README.MD files and will spend many hours solving all the errors and incompatibilities that will be presented.
  • Most of the packages use a bunch of build tools and dependency managers. It's almost impossible to keep track of the updates and changes in the packages and sub-packages. If using development versions frequently some features might break from one update to the other.
  • Laracasts: Not everyone prefers to watch videos instead of reading a well documented guide.
  • Confusing folder organization.

Yii 2

Strengths

  • Can be installed by downloading a zip package, no composer or other package managers required (you can use them as well).
  • Out-of-the-box CRUD generation with functional views, controllers, search functions, models, etc...
  • Out-of-the-box user authentication with ACL/roles and permission modules.
  • Official standard site boilerplate with user authentication and Bootstrap views. With a few more clicks you can also have a CRUD interface right from your tables.
  • Intuitive folder organization.
  • Custom widgets for functional PHP/HTML snippets. Very useful while building dashboards.
  • Built-in widgets that render data tables as plain HTML or using AJAX dynamic views.
  • Bootstrap and JQueryUI widgets. Create a working page menu without external modules.
  • HTML helpers to generate tags and form components from your code.
  • Debug toolbar for displaying technical data and statistics during the code execution.
  • Powerful internationalization and translation tools for multi-language applications.
  • Excellent and very detailed official documentation.
  • Centralized information resources in the official website.
  • Mature development cycle. No extravagant or revolutionary changes every 6 months.

Weakness

  • Less user contributed extensions than Laravel.
  • Less commercial extensions than Laravel.
  • Coding looks more polluted because of the extensive use of PHP arrays instead of single object properties.
  • Different configuration files for different environments can be quite confusing.
  • Version 2 is still too new and most tutorials, documentations and extensions will take a while to be updated.

Personal veredict

Laravel, according to their own website is a framework for artisans and we all know artisans look for the perfection instead of an average or "good enough" solution. During my use of this framework I found myself trying to find the perfect modules for a perfect integration and elegant solutions for all my problems. Unfortunately that takes time, a lot of time, mainly because you have to learn and integrate each one of the extensions as if they were a new framework. Laravel developers got rid of very important key modules for a web application relying on third parties. This could be one of their positive aspects but became their largest weakness. Many (to not say most) of the extension suppliers didn't followed Laravel philosophy and came with ugly, messy and buggy codes, a lot of redundancy and sometimes very serious security flaws. Those extensions were fixed and modified by the users and generated thousands of forks and variations. Nowadays the extensions and modules are so dispersed that finding the right piece of code might be more difficult than coding a complete new solution from scratch, that kills the main benefits of the frameworks (saving time).


Yii2 is a All-in-on out-of-the-box solution. Yii takes into consideration that a web application is not only made of PHP scripts but also HTML and JavaScript and handles them all. Unzip a package and have a simple web application operational in a few minutes or hours with the Gii generators and the standard site templates. Working on an already functional code makes the development faster than ever. If you need some common usage features (like a pop-down menu or an authorization model) they will be there, ready for you. No extensions required neither new coding practices learning curves. The single resources center (Yii website) and the centralized development really help in terms of finding what you need faster and keeps all features and codes in the same tracks and standards. Of course maintaining all those features working in harmony takes a lot of efforts so the developers can't make significant upgrades or changes too often. What I really love on Yii2 is that the security features (authentication, authorization and other protections) are integrated in the core code, this is very important especially for larger enterprise services.

Tags

The content of this field is kept private and will not be shown publicly.
CAPTCHA
14 + 2 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.
Protected by Spam Master