New features and changes in Laravel 5.4

New features and changes in Laravel 5.4

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. <div class="alert">
  3. {{ $slot }}
  4. </div>

Now you can inject it into your template like this :

  1. @component('message')
  2. Your message
  3. @endcomponent
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

Phone: (+91) 8800417876
Noida, 201301
sakarya escort sakarya escort bayan sakarya escort serdivan escort sakarya escort sakarya escort serdivan escort
karasu escort akyazı escort serdivan escort akyazı escort ferizli escort sapanca escort serdivan escort söğütlü escort sakarya escort izmit escort arifiye escort erenler escort hendek escort kocaali escort pamukova escort taraklı escort geyve escort