Why we chose Laravel for Bespoke Web Applications
As an agency we have been building bespoke web applications for 15+ years. Almost always our clients are after some combination of:
- Quality & stability
- Performance & scalability
- Low cost & short timeframes
For most of these years our custom projects were built on top of a Content Management System we developed in-house called “SiteHQ”. As it’s code base has grown and the web has evolved it has become more difficult to achieve the above 4 goals, so we’ve been looking around for a suitable replacement.
As web nerds we’ve dabbled in various technologies and frameworks over the years. We’ve even built a couple of projects using Laravel including an API for an ecommerce iOS App, and another which was a SaaS solution for trades to make quoting on jobs really easy. While Laravel was specifically chosen for those 2 projects we felt that Laravel would be a great fit for all future projects as it really nails our primary four goals. Here’s why:
Quality & stability
- Well documented
- Well known
- Test Driven Development (TDD) friendly
- DB migrations
Laravel is the most starred backend framework on Github. The docs are beautifully laid out, the core framework is impeccably commented, and there’s plenty of community support and learning resources. This makes it easy to onboard our team and enjoyable to work with. It also means there is no vendor lock-in for our clients.
Test Driven Development (TDD) is available out of the box and supported as a first-class citizen. TDD revolves around the idea of writing tests first, implementing the minimum code necessary to get that test passing, and then refactoring to clean up the implementation. Using TDD ensures quality tests are in place for all features and gives developers the confidence to fearlessly refactor the codebase knowing they’ll be alerted to any regressions. This will help our team keep projects lean and stable for years to come.
DB migrations ensure changes are performed in a consistent and repeatable way. They become really useful when multiple developers are involved in a project, or as the project shifts from the development / launch phase into the maintenance phase. Without migrations it’s easy to lose track of which DB changes were made in order to fix a bug or implement a new feature. I love how even the DB structure is described as code and can be tracked in Git.
Performance & scalability
- Interoperable with cloud services
- Can be load balanced
- Real-time (using Pusher)
- Background jobs & asynchronous processing (using Queues)
- Scheduled (CRON) tasks
Laravel applications perform well and are cost efficient when setup on a single server (running Apache/Nginx, MySQL, Redis etc). As more resources are required it is easy to separate MySQL & Redis into their own dedicated servers. If the application needs to handle a massive volume of traffic Laravel also runs well when deployed across several servers behind a load-balancer / proxy.
Laravel supports a variety of Amazon services, making it easy to grow beyond a single server as demand for the application increases:
- SES (email sending)
- SQS (background jobs / queues)
- Elasticache (Redis caching & PHP sessions)
- S3 (file storage)
With scheduled tasks I love that we only have to set up a single job in Crontab and the rest is done in code. It’s easy to see exactly what jobs were added/removed/changed over time (using Git). CRON’s can even be run safely in a multi-server environment.
Low cost & short timeframes
- Reasonable defaults
- Artisan can scaffold out classes
- Import from Packagist
- Easy to build custom JSON API’s
- DB migrations & seeds
In short, it’s faster for us to start working on actual features with Laravel as the boilerplate is taken care of (which normally takes us time, but provides no benefit to the client). Artisan’s “make” commands which help generate new models, controllers, factories etc is one example of how we can get started quickly.
Using Packagist & Composer we can import a wide range of quality components from the community. This enables us to focus on implementing features (eg. sync data with Infusionsoft & Xero, or offer single-sign-on with Office 365) rather than setting up API helper classes or auth schemes.
Given the trend towards Single Page Applications (SPA’s), “headless” and multi-client applications I really appreciate how easy it is to build JSON API’s complete with authentication, rate-limiting middleware etc. Most of the work is done out of the box. It makes it easy to bolt-on a frontend of choice (eg. React Native mobile app, Amazon Alexa, IFTTT).
DB migrations & seeds make it much faster for new developers to get up and running with a fresh database, complete with auto-generated sample data. As an agency this reduces the setup time and inherent risk in swapping between team members, meaning we can more freely allocate our team resources and improve our internal efficiency.
- Open source & actively maintained
- Incorporates many PHP & web best practices
- Built-in authentication with strong password hashing
Being an open source project the framework is constantly scrutinised by the community who contribute security patches when flaws are found. Security patches and bug fixes are published weekly, and major releases are published every 6 months.
Laravel also offer Long Term Support (LTS) releases, giving more risk-averse clients the peace of mind the foundation of their application is not going to become unsupported in a short period of time.
In most cases security doesn’t make products more profitable, but it does have the potential to inflict significant harm, so we really appreciate how the Laravel team have given this thought and encouraged good security patterns and practices throughout the framework and in the docs (eg. XSS and CSRF protection, mass assignment in models).
Out of the box Laravel ships with a user authentication system, enabling the right people to access the application and API. It uses Bcrypt or Argon2 for password hashing, both of which can be adjusted to counter future increases in compute power (keeping the passwords difficult to crack).
Our next steps
Laravel has all the right pieces we need to build an application quickly, keep it well maintained and scale it up as demand grows. The framework itself is expressive and elegant, making it fun for developers to work with. We’re excited to build out future bespoke projects using the framework.
Currently we’re working on a frontend boilerplate for the Voyager Admin interface (which runs on Laravel). We’re also working on building out a few modules & features our clients commonly request (and previously offered in SiteHQ).
I’m sure we’ll have more to share of our adventures with Laravel in the future!