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…
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.
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.
Laravel 7 allows you to define your own components and use them in your blade files like below:
<?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'); } }
<div class="notify {{ $classForType() }}"> {{ $heading }}{{ $slot }} </div>
<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 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.
It is mainly developed for a request to API endpoints.
<?php use Illuminate\Support\Facades\Http; $response = Http::post($url); $response = Http::post($url, [ 'site' => 'Laravel 7', ]);
$response = Http::get($url); $response = Http::get($url,['xyz'=>'pqr']);
$response = Http::withHeaders(['xyz' => 'pqr'])-> post($url, [ 'baz' => 'qux', ]);
$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.
A new artisan command is added in Laravel 7 which is
php artisan test
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.
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.
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.
Subscribe to our newsletter and learn about the latest digital trends.