Writing code in vanilla PHP is like Fred Flintstone guest-starring in the Jetsons. You’ll spend all day re-inventing the wheel and achieving nothing, while the robot maid already has a working back-end and user registration flow, and is now drinking whatever passes for whiskey in the far-flung future. And laughing at you.
Laravel’s fundamental mission is to save developers time. The time spent building nested validation rules, database queries and debugging horrendous spaghetti can all be clawed back. Laravel provides hundreds of out-of-the-box solutions to common project requirements. Low barriers to entry mean you can get up and running rapidly; moving from PHP to working in Laravel is straightforward and the documentation is best in class.
Put down the PHP. Here’s everything you need to know about Laravel in 2021.
Laravel makes creating, altering and dropping tables in your database a simple task; so simple in fact that for long-running projects you may end up with a hauntingly large migrations directory. With the latest version, the framework has the ability to squash that directory. This way, instead of a long list of migrations that become more inscrutable as time goes on, you have a single SQL command that builds your whole database at once. New migrations will be added as normal. This offers a way of reducing the technical debt and complexity, especially when handovers are involved, and the new set of developers will have one less thing to worry about.
Pushing a new application live usually comes with a few teething problems that need ironing out over the subsequent days. Rather than panicking, staying up all night and trying to perfect that time-machine plan, you can now use Laravel’s maintenance mode. When you want to make changes or test features on a new application that’s already in production, maintenance mode essentially hides your application from end-users while you work on it. A secret cookie allows a developer to work on the application, while all other users will be presented with a pre-rendered error message instead. It’s all done with a command, and all reversed the same way.
No client wants their business to suffer any downtime. However, maintenance mode means instead of a potentially broken application and a blank screen, users will be met with a clear message and the knowledge that the issue will be put right soon.
For the first time, Laravel comes with TailwindCSS as standard. This comes after years of users removing bootstrap and adding Tailwind manually after fresh installs. Tailwind’s developers describe it as a “utility first CSS framework packed with classes…that can be composed to build any design, directly in your markup”. You’ll never need (or want) to work with CSS files ever again. There’s no overbearing style restrictions or build requirements, and custom style rules can be added by extending themes. Using Tailwind means fewer files, which means less dreaded technical debt and a longer lifespan for products. New features will take less time to build, too.
Added as an open-source package, Laravel Jetstream provides a comprehensive scaffold that includes login, two-factor authentication and session management. It’s all built with TailwindCSS and your choice of either Inertia or Livewire. In theory, it should save you time just like everything else in Laravel but unfortunately, the community is split on Jetstream; there are complaints that it’s bloated and introduces complexity where it didn’t exist before.
At Purr, we have been looking at splitting the difference. Instead of committing to Jetstream as a whole, we are going to use a Breeze/Inertia combination. This will allow us to be mindful of security as we build SPAs (Single-Page Applications) that don’t require front-end routing solutions like Vue Router. We believe this solution will offer clients a fast and robust application that can handle a variety of user behaviour from accidentally idiotic to deliberately malicious.
Some clients are technical, some aren’t. Some clients have a little development experience, and some are uncomfortable with everything since 8-inch floppy disks. Regardless of ability or knowledge, it’s always going to be desirable for clients to be able to make changes to their applications themselves. If a client just wants to adjust some text, it seems a waste of time and resources to need to enlist a developer to make the change. Laravel lends itself extremely well to the creation of applications with a customer-facing frontend and an admin panel for the management of various aspects of the application. For some clients, this could mean website text, for others the management of user data, passwords or preferences.
And it gets even better: your application’s backend can be used with other existing applications you may have, creating a single source of truth and a way of managing your data and your business from one place.
We have seen clients cobble together a working platform for their business by combining several different third party applications – one for lead management, another for internal operations, another for time management, another for holding their place in the queue at McDonald’s. It is this client that would benefit most from the inclusion of a Laravel application in their lives. They can transition from the multi-faceted chaos, and use permissions to control who can see what, allowing all employees to use the same system for everything.
Laravel and legacy
When a client pays for a top-shelf product, they hope that their application will last for years to come. Given the dizzying array of tech stacks and the rapid pace of technological advancement, this hope is often in vain, particularly if the application was built haphazardly in the first place. Even long-standing technologies are subject to the ravages of time (AngularJS has passed the EOL mark this year, for instance), and Laravel is no exception. The major difference between Laravel and some other frameworks is how straightforward it is to upgrade your project to the latest version. Endorsed by the creator of Laravel, a service called Laravel Shift even exists to handle upgrades for either an annual fee or on a pay as you go basis.
If you’re considering a new project then consider Laravel in 2022, get in touch here.