Why I Chose Laravel As My Backend Framework
Justin Ho
Posted on October 5, 2020
Photo by Marcus Lenk on Unsplash
What is Laravel?
Laravel is an open-source back-end web development framework using the PHP programming language. The beauty of Laravel is its expansive and vetted ecosystem of packages which were all built to compliment the base framework.
For those coming from NodeJS like myself, you begin the appreciate the "convention over configuration" mindset this framework brings as you sift through its thorough documentation with examples for every possible thing you want to do.
No more webpack vs gulp, typescript or no typescript, or eslint vs some new code linter. Laravel brings me a feeling of calm because the ecosystem is uniform and each package is responsible for one thing and one thing only.
What this Article is about
Despite the title, this post isn't really a step by step guide on setting up Laravel, the documentation is very thorough on that. Instead, what I want to highlight is the different approach Laravel takes to development if you are coming from a NodeJS or another back-end framework.
The Development Experience
An important aspect of programming that is often ignored is the experience for the developer writing the code. How easy does the software allow you to make changes? What kind of friction does the developer encounter? I'll be going over a few things the framework has built-in for a smoother experience.
Development Environment
It's currently 2020, Agile and DevOps should not be buzzwords anymore. As a developer, you should be conscious of the production environment as early as possible, and that means using tools to ensure your development environment is as reproducible and free of unnecessary dependencies as possible.
Laravel offers a fully documented method of a development environment through the use of a Vagrant managed virtual machine called Homestead. For those unfamiliar with Vagrant, it's a development environment configuration and management tool which can work with local virtual machines or even resources on the cloud. The benefit of Homestead is that you get an ephemeral virtual machine which will always be the same when you turn it on. The only drawback with this approach is that your host machine (the base computer) will still need the PHP, Composer, and Vagrant dependencies to make it work.
Package Management
Just like the NodeJS NPM ecosystem, PHP has its own package manager known as Composer, which works almost the exact same way: using a configuration JSON file to include versioned dependencies for your project.
The Artisan CLI Tool For Web Artisans
Artisan, a CLI Tool, is where Laravel starts differentiating itself from other fragmented frameworks. In many NodeJS frameworks, you have to install a new CLI tool to work with custom commands for scaffolding; for example, create-react-app
, gatsby-cli
, etc. With artisan, it's the ONLY CLI tool you need to use (other than composer for package commands) to scaffold and interact with your Laravel application.
If you need to test, php artisan test
automatically links to PHPUnit (the default testing framework). If you need to create a new Eloquent ORM model, there is php artisan make:model
. If you add an extra package such as Livewire for dynamic interfaces? Artisan now has extra commands to interact with that too.
The Ecosystem
Finally, this part is where Laravel excels, having separate packages for authentication + authorization, integration with other systems such as stripe and OAuth providers, as well as hosting providers in both cloud and serverless form.
I looked through all the package documentation and found that it was consistently of good quality (other than the newest member, Jetstream) and provided examples that integrated itself with Laravel.
Closing Thoughts
Although NodeJS has an enormous NPM ecosystem, sometimes it can feel very fragmented and the quality is very hit or miss with both the functionality and the documentation of the packages. On the other hand, Laravel works within the confines of its ecosystem and provides an "it just works" mentality to all its included packages, while still allowing you to extend its capabilities through composer for additional packages.
I hope this gave you some insight into the Laravel framework and why it could be your choice for your next project.
If you want to read more, see my project series where I refactor a vanilla PHP app onto Laravel.
Feel free to connect with me on Twitter @justinhodev.
Posted on October 5, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.