Laravel 7 is Released Now! What's New in Laravel 7 Release - KrishaWeb

CREATE COMMUNICATE CONNECT

Awesome Experiences Brand Stories Your Customers

Thursday, Mar 05, 2020 / Tech News / KrishaWeb

Laravel 7 is Released Now! Explore What’s New in Laravel 7

Laravel 7 Release
Laravel 7
has been released on 3rd March 2020. This is not LTS version so according to Laravel version support policy, they will provide 6-month bug fix until 3 September 2020. The big news is Laravel will release a new major version every 6 months.

Here you can see what new features you are getting in Laravel 7…

  • Laravel Airlock
  • Better routing speed
  • Blade component tags
  • Fluent string operations
  • A new HTTP client
  • New artisan commands
  • Multiple Mail driver
  • CORS support

Laravel Airlock

It is mainly built by Taylor Otwell. Laravel Airlock provides an easy authentication system for mobile applications, single-page applications and simple token-based APIs applications. It will allow each and every user of your application to generate multiple API tokens for their account. All these tokens may be granted abilities which specify which actions the tokens are allowed to perform.

For more information on Laravel Airlock, consult the Airlock documentation.

Better Routing Speed

Laravel 7 will give 2x faster speed than Laravel 6 using route:cache. One more best feature is defined as Route Model binding. Using this feature you can bind your Model in your route.

Route::get('users/{user:slug}', function (App\User $user) {
return $user;
});

For more information on route model binding, please consult the routing documentation.

Blade Component Tags

Laravel 7 allows you to define your own components and use them in your blade files like below:

Define Component
<?php 
namespace App\View\Components; 

use Illuminate\View\Component;

class Notify extends Component

{

   public $type;

   public function __construct($type)

{

      $this->type = $type;
}

   public function classForType()
{
      return $this->type == 'success' ? 'notify-success' : 'notify-warning';
}

   public function render()
{
      return view('components.notify');
}
}
Make Component Tag
<div class="notify {{ $classForType() }}">

{{ $heading }}{{ $slot }}

</div>
Using it in Blade files
<x-notify type="error" class="mb-4">
<x-slot name="heading">
Alert content...
</x-slot>
Default slot content...
<x-notify>

Please consult the full Blade component documentation to learn about this feature.

Fluent String Operations

Fluent string operations were developed by Taylor Otwell.

You are likely familiar with Laravel’s existing Illuminate\Support\Str class, which provides a variety of helpful string manipulation functions. Laravel 7 now offers a more object-oriented, fluent string manipulation library built on top of these functions. You may create a fluent Illuminate\Support\Stringable object using the Str::of method.

A variety of methods may then be chained onto the object to manipulate the string:

return (string) Str::of(' Laravel Framework 6.x ')
->trim()
->replace('6.x', '7.x')
->slug();

For more information on the methods available via fluent string manipulation, please consult its full documentation.

A New HTTP Client

It is mainly developed for a request to API endpoints.

POST Request
<?php

use Illuminate\Support\Facades\Http;
 
$response = Http::post($url);
 
$response = Http::post($url, [

'site' => 'Laravel 7',

]);
GET Request
 $response = Http::get($url);
 $response = Http::get($url,['xyz'=>'pqr']);
With Header
$response = Http::withHeaders(['xyz' => 'pqr'])->
post($url, [ 
'baz' => 'qux', 
]);
Response
$response['xyz'] 
$response->body() 
$response->json() 
$response->status() 
$response->ok()

To learn more about all of the features of the HTTP client, please consult the HTTP client documentation.

New Artisan Command

A new artisan command is added in Laravel 7 which is

php artisan test

Multiple Mail Drivers

An additional feature in Laravel 7 is that you can now configure multiple Mail drivers in a single application. Each mailer configured within the mail configuration file may have its own options and even its own unique “transport”, allowing your application to use different email services to send certain email messages. For example, your application might use Postmark to send transactional mail while using Amazon SES to send bulk mail.

By default, Laravel will use the mailer configured as the default mailer in your mail configuration file. However, you may use the mailer method to send a message using a specific mailer configuration:

Mail::mailer('postmark')
->to($request->user())
->send(new OrderShipped($order));

For more information on Markdown mail, please consult the mail documentation.

CORS Support

Laravel 7 includes first-party support for configuring Cross-Origin Resource Sharing OPTIONS request responses by integrating the popular Laravel CORS package written by Barry vd. Heuvel. A new cors configuration is included in the default Laravel application skeleton.

For more information on CORS support in Laravel 7.x, please consult the CORS documentation.

Wrapping Up!!!

Find out more about Laravel 7

These are just a few of the new features in Laravel 7 and to see a complete list check out the release notes as well as the upgrade guide.

divider
DOWNLOAD THIS FREE EBOOK OF

Website UI/UX guide for 2019

Download this free ebook of

A Detailed Explanation Of The WordPress Platform

Guide to Improve UIUX Design of Your Website to Boost Conversion

SEO Checklist for E-Commerce Website

Ecommerce SEO Checklist 2020

eCommerce Conversion Rate Optimization Techniques for 2020

Website Footer Design Guide

Website Footer Design Guide
DOWNLOAD THIS FREE EBOOK OF

Intermediate Guide For WordPress

Intermediate WordPress Guide
Landing Page Optimization Tips and Best Practices

Complete Guide to Landing Page Optimization

Landing Page Optimization Resource
line

You have a visionWe know the way to get you there.