Top 3 new features in Laravel 5.4

Top 5 new features in Laravel 5.4

Laravel 5.4 continues the improvements and refactoring of framework made in Laravel 5.3 by adding support for plenty of modules and new features. We will discuss top 3 new features in Laravel 5.4 that made the framework more adaptable since released.

Moving on, we’d love to list the top 3 new features in Laravel 5.4 which makes it more adaptable-

1. Laravel Mix

As part of Laravel 5.4, Laravel Elixir has been upgraded and renamed to Laravel Mix. Mix is very similar to Elixir with differences of implementation over Webpack instead of Gulp previously in Laravel 5.3. A quick look at the default files for Elixir and Mix:

Looks very similar, but there’s one big difference you will experience once you will run: with Elixir you run the code with gulp or gulp watch while with Mix you will run the code with npm run dev or npm run watch. You can generate production ready minified version of your assets using npm run production.

2. Laravel Dusk

A new way of application testing introduced in Laravel 5.4 as Laravel Dusk, which provides an expressing, easy-to-use browser automation and testing API. Dusk is based on standalone ChromeDriver installation. Dusk operates using a real browser, you are able to easily test and interact with your applications:

Dusk changed the way applications testing work in Laravel. When you write application tests, Dusk sends your commands to ChromeDriver, which then spins up Chrome to run your tests in the browser and reports back your results.

3. Components and Slots in Blade Template

In Laravel 5.4, Blade offers a new @component directive. Using this directive we can create more reusable components with the help of slots. Lets imagine a reusable ‘breadcrumb’ component we would like to reuse throughout our application:

Above code snippet, includes one default slot {{ $slot }} and 2 named slots {{ $secondSlot }} and {{ $thirdSlot }}. The default slot, {{ $slot }} variable will contain the first level breadcrumb like home, dashboard, Admin r anything we wish to inject into the breadcrumb component. We will use @component Blade directive, like this:

Named slots allows you to put multiple slots into a single component. Named slots may be injected using the @slot directive. Any content is not within a @slot directive will be passed to the component in the {{ $slot }} variable.

Clude Con

That’s all, folks. Enjoy! Remember, you can still keep writing the code you’ve always written–and you can even pull in the old package, if you’d prefer. But there’s a whole new world open to you now. Try it out a bit. If you are having any queries and confusions then lets discuss in comment section.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.