New features and changes in Laravel 5.4

New features and changes in Laravel 5.4

In this post we will give you information about New features and changes in Laravel 5.4. Hear we will give you detail about New features and changes in Laravel 5.4And how to use it also give you demo for it if it is necessary.

New features and changes in Laravel 5.4

Laravel 5.4 was released on Jan 24, 2017 with lot’s of new features and improvements such as Sanitizing Middleware,Higher order messages,From Elixir to Mix,Fluent Routing,Components and Slots,Real-Time Facades,Laravel dusk etc.

As we know, Laravel is one of the most popular framework for PHP developer and it continues the improvements in their versions so we can say it’s that time of year again Laravel came with new version from 5.3 to 5.4

Kindly have a look on official changes in Laravel 5.4

Request Sanitization Middleware

There are two new middleware added in the default middleware stack in Laravel 5.4 :

  • TrimStrings Middleware will automatically trim/remove all white spaces comes with request data that means when you add extra spaces in your form field then it remove those white spaces automatically.
  • Here is example where you will see if you remove TrimStrings Middleware then it will return you response with extra white spaces and if you add TrimStrings Middleware then it remove extra white spaces from request data.

    Without TrimStrings Middleware :

// ' '

With TrimStrings Middleware :

// ''

  • ConvertEmptyStringsToNull Middleware will automatically convert all empty string to null value that means any field of form is empty or embeded with empty string then it convert back to null value.
  • Here is simple example for ConvertEmptyStringsToNull Middleware.

    Let’s assume i have a text input field that take title of project :

    If i do not use ConvertEmptyStringsToNull Middleware and i left text field blank then response will be :

    // ''

    If i use ConvertEmptyStringsToNull Middleware then this will now return null :

    // null

    Blade Components and Slots

    In Laravel 5.4, there is new features added with Blade template called @component directive.

    Blade Components and Slots features are similar to sections and layouts.The features are desgined to provide you more flexibility in your blade templates.

    You can use this features for those components that will be reusable throughout your application.

    Example :

    Let’s have a example for showing an alert message :

    1. <!-- /resources/views/message.blade.php -->
    2. <divclass="alert">
    3. {{ $slot }}
    4. </div>
    <!-- /resources/views/message.blade.php -->
    <div >
        {{ $slot }}

    Now you can inject it into your template like this :

    1. @component('message')
    2. Your message
    3. @endcomponent
        Your message 

    The whereKey method

    The whereKey method is new feature added in Laravel 5.4. The whereKey($id) method is used add dynamically where clause for given primary key to find record.

    You can click here to know more about whereKey method in details with example.

    laravel 5.4 New Features – The whereKey method with example

    Kindly keep in touch, we will update more on this post ASAP.

    Label :


    Laravel PHP Framework


    Web Development

    Hope this code and post will helped you for implement New features and changes in Laravel 5.4. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

    For More Info See :: laravel And github

    Leave a Comment

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

    6  +  1  =  

    We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US