Laravel is een opensource PHP-framework waarmee webapplicaties volgens het model-view-controller-ontwerppatroon kunnen worden ontwikkeld. Achter Laravel staat een uitgebreide community en er is uitgebreide documentatie. Niet voor niets is het naast Symfony en Yii een van de meest populaire PHP-frameworks van dit moment. Eerder deze week is versie 5.4 van Laravel uitgekomen en de release notes daarvan zien er als volgt uit:
Laravel DuskLaravel Dusk is an end-to-end browser testing tool for JavaScript enabled applications. It aims to provide the right way to do page interaction tests, so you can use Dusk for things like click buttons/links, forms, as well as drag and drop!
Dusk utilizes the ChromeDriver and the Facebook Php-webdriver for tests. It can work with any Selenium browser, but comes with ChromeDriver by default which will save you from installing a JDK or Selenium.
Dusk is very easy to use without setting up Selenium and starting the server every time.
Laravel MixLaravel Mix is the next generation of Elixir. It is built with webpack, instead of Gulp. It was renamed because of the significant changes.
Unless you customized your Elixir setup, moving to Mix shouldn’t be a problem and Laracasts has a video covering this updated tool.
Blade Components and SlotsComponents and Slots are designed to give you even more flexibility in your Blade templates. As an example, imagine you have an include template that is used for showing an alert:
// alert.blade.php <div class="alert"> {{ $slot }} </div>
Then, in your template file you can include it like this:
Markdown Emails
@component('inc.alert') This is the alert message here. @endcomponent
Laravel 5.3 introduced two new features around email, Mailables and Notifications which allow you to send the same message through email, SMS, and other channels.
Building on top of these improvements, Laravel 5.4 includes a brand new Markdown system for creating email templates.
Under the hood, this feature implements the Parsedown parser with its companion, Markdown Extra so you can use tables.
Automatic Facades
@component('mail:message') # Thank You Thank you for purchasing from our store. @component('mail::button', ['url' => $actionUrl, 'color' => $color]) {{ $actionText }} @endcomponent @endcomponent
You can now use any class as a Facade on the fly. Here is an example:
namespace App; class Zonda { public function zurf() { return ‘Zurfing’; } }
Then, in your routes or controller:
Route Improvements
use Facades\ { App\Zonda }; Route::get('/', function () { return Zonda::zurf(); });
Another new feature is the ability to use fluent syntax to define a named route or a middleware:
Route::name('profile')->get('user/{id}/profile', function ($id) { // some closure action... }); Route::name('users.index')->middleware('auth')->get('users', function () { // some closure action... }); Route::middleware('auth')->prefix('api')->group(function () { // register some routes... }); Route::middleware('auth')->resource('photo', 'PhotoController');
The route caching layer also received improvements which will allow route matching on very large applications to see a significant enhancement.
Higher Order Messaging for CollectionsThe best way of showcasing this new feature is through code samples. Pretend you have a collection, and you want to perform an operation on each of the items:
$invoices->each(function($invoice) { $invoice->pay(); });
Can now become:
More New Features$invoices->each->pay();
Some other changes and improvements include the following:
- New
retry
helper- New
array_wrap
helper- Added a default 503 error page
- Switched to the
::class
notation through the core.- Added names to password reset routes
- Support for PhpRedis
- Added IPv4 and IPv6 validators
date_format
validation is now more precise