Friday, 12 January 2018

What is new in Laravel 5.6 ?

Laravel 5.5 was released on August 30, 2017 and is the the current stable version of Laravel. Laravel 5.5 is the latest LTS(Long Term Support) version of Laravel. It is just 4 months of releasing f Laravel 5.5 and Laravel 5.6 is ready to release.

Laravel 5.6 is scheduled to be released in January 2018.Even after the release of Laravel 5.6, Laravel 5.5 will keep receiving the bug fixes as it a LTS(Long Term Support) version of Laravel.
what_is_new_in_laravel_5.6

There were many new features in Laravel 5.5.If you have not seen it yet or if you have not used Laravel 5.5 and want to use then you can see the new features in Laravel 5.5 here - Laravel 5.5 New Features.You can learn more about Laravel release process here - Laravel Release Process.If you want to get notified when new versions are released then Laravel News offer an instant notification email for new posts on their site and a weekly Laravel newsletter that you can join and be notified as soon as it's released.

What is New in Laravel 5.6 ?

1) Laravel 5.6 will Remove the Artisan Optimize Command

The Artisan optimize command is deprecated as of 5.5, and a commit in master has already removed it from 5.6. Waiting until 5.6 gives you time to update your build scripts and composer.json files ahead of the release.

As of Laravel 5.5, the composer.json no longer references optimize in the post-install-cmd and post-update-cmd scripts. The Optimize command is still defined, but does nothing in 5.5.

The 5.5 upgrade guide explains the reason for the deprecation:
With recent improvements to PHP op-code caching, the optimize Artisan command is no longer needed. You should remove any references to this command from your deployment scripts as it will be removed in a future release of Laravel.
You can see the removal in master and more discussion around the removal, where Taylor Otwell had this to say about the timing:
We’ll remove it in 5.6 and note in the upgrade guide for 5.5. It can break deployment scripts that are calling it if we remove it without warning.
Laravel 5.5 also requires PHP 7, so you should be safe to remove any reference to this command now if you’ve upgraded. Be sure to remove the command from your composer.json post-install-cmd and post-update-cmd scripts ahead of the 5.6 release next year.

2) New Blade Directives Coming to Laravel 5.6

Laravel 5.6 will include two new form blade directives for cross-site request forgery (CSRF) and HTTP method input, thanks to Taylor Otwell.

In Laravel 5.5 you do the following at the top of forms to create hidden inputs for the CSRF token and the spoofed HTTP method:
<form>
  {{ csrf_field() }}
  {{ method_field('PUT') }}
  <!-- ... -->
</form>

Starting in Laravel 5.6 you can do the following instead:
<form>
  @method('put')
  @csrf
  <!-- ... -->
</form>

Laravel makes it easy to protect your site against CSRF attacks without any work on your part. However, if you want to submit a form successfully you must include a CSRF token input to verify that the form submission came from the application and not from another site.

Secondly, since HTML forms can’t make PUT, PATCH, or DELETE requests you need to add a hidden _method input to spoof these HTTP verbs. Laravel uses the _method input to route the request to the appropriate controller action correctly.

These directives will be out with Laravel 5.6 when it ships next year! Here’s the commit if you want to see the source code related to this feature.

I feel like the new directives are more instinctive and more natural to remember, however, the helper functions are still available for use if you prefer.
Previous Post
Next Post

post written by: Dhaval Thakkar

Dhaval Thakkar is an enthusiastic web developer who is passionate about learning new things and always ready to help other developers.Just Web Code is a way to provide web solutions to web developers.

0 comments: