This is contributed post for Computer Weekly Open Source Insider written by Max Gilbert in his capacity as software developer at Preston UK based web design agency Blue Wren – a firm that builds bespoke and hybrid software applications to tackle operational inefficiency.
In this part #2 of two posts, Gilbert looks at Laravel, a free and open source PHP web framework.
As a Laravel-advocate, Gilbert has contributed this piece to examine the upcoming Laravel update, discussing some of the most notable upgrades and the practical application and implications of these advancements.
Gilbert writes as follows…
The much-anticipated Laravel update is about to drop… and, by now, I’m assuming you’ve rubber-necked at some of its new features. Well, this is the second part of our Laravel 5.5 preview, so check out part one here if you missed it, or read on to find out what these changes mean to us users of the Laravel framework.
This is something that all Laravel developers are likely to be acquainted with. The migrate:refresh command allows you to rollback and re-run all of your migrations; a huge help when rebuilding a database during development.
With Laravel 5.5, though, there is a new command… Fresh.
This differs from refresh in that instead of performing the actions in all of the down methods in your migrations, it just drops the database and runs all your migrations from the start. This is set to save developers a great deal of time, removing the need to go into your local instance of Adminer or phpMyAdmin and manually dropping the database.
Front end presets
Since Laravel 5.3, Vue.js and Bootstrap have been shipped as an optional scaffolding; the idea being, the latest tools are at your disposal to get your project off the ground.
Front end frameworks change faster than the weather, which is something that 5.5 considers.
With 5.5 you can now run the artisan pre-set command to switch out Vue for React, just the Bootstrap CSS or even the option to have none. This gives greater freedom and flexibility for developers to choose which front end perks they want (if any at all) in their Laravel projects.
Error pages receive a revamp
Errors will now extend from an errors::layout file and will be that little bit slicker in their aesthetics. They will make use of flexbox to nicely centre them vertically.
Why is this a good thing? Well, who doesn’t love a bit of glamour with their errors?
PHP 7 now required
Laravel has always been a framework that likes to push things forward, and that isn’t about to change any time soon. From 5.5, Laravel now requires PHP 7.0.
With the recent announcement from Tumblr – showing how moving to PHP 7 decreased the CPU load on their servers by 50%, and immediately reduced the latency by half – it’s no wonder that Laravel want to encourage using the latest version of PHP. The impact that this should have for Laravel is obvious, presenting it with a great foundation to speedily operate its continually evolving features.
Laravel Package Auto-Discovery
Each Laravel package has something in common… when reading its readme file, you will notice each requires three steps: composer require…, register the provider in app.php, and optionally register the façade.
Laravel 5.5 provides a new way for package developers to register their service providers and aliases in the package composer.json file, removing the need for the other two steps.
So, when installing new packages, the steps will now be easier and more streamlined, as composer require… will be the only action needed.
LTS (Long Term Support) Version 5.1 was Laravel’s first ever LTS release, and its two years of bug fixes will come to an end this year.
While this may be classed more as a selling point than a feature, thankfully 5.5 has been confirmed as the next LTS release. As such, this means a further two years of bug fixes and 3 years of security updates, adding even more stability and support to the Laravel platform.
vendor:publish prompts you to pick a provider
In previous versions of Laravel, running the vendor:publish command would publish everything that it found, including views, migrations and even configs.
As of 5.5, running the publish command without any flags will prompt you to pick a provider, or tag, which makes it easier to only publish exactly what you want.
This is a notable improvement as it gives you more granular control when publishing vendor content. And if you want to override this? Simply specify the –all or –provider flag.
Laravel throw_if and throw_unless helpers
…Or, in their shortest form, Exception Helpers. These are helpers that 5.5 brings in to make it easier to throw exceptions. And these two new helpers do exactly what they say on the tin.
The throw_if helper will throw an exception if the first parameter is true. The throw_unless helper will throw an exception if the first parameter is false.
As with other Laravel feature updates, these give more control, specifically over exception handling.
Not only do they give flexibility on the type of exception to throw, but also the message to display with it. Just another example of Laravel’s quest to make its platform that bit more optimised.
So in all then, 5.5 continues to support Laravel’s drive for continued improvement. It looks set to make dev-life that bit more streamlined with this new user-intuitive update and, as a Laravel developer, it seems poised to optimise the way we work with the platform.