Read Story
Watch Main Stage Talk
Download Now
Ayush Bhatt

What’s new in Laravel 7 ? Major Update ?

Introduction

Recently, Laravel released it’s 7th version of the framework officially on 3rd March 2020. Although it isn’t the LTS update but it brings a lot of new cool features and previous fixes. It is one major update according to the Laravel’s version support and update policy. This update will provide the bug fixes for the next 6 months ( September 3, 2020 ) and 1 year security fixes ( March 3, 2021).

The new features arrived with the Laravel 7 are:
1. Laravel Airlock
2. Zttp for Http Client
3. CORS Support
4. Fluent String Operations
5. Custom Eloquent Cast
6. Blade X
7. Customizable  Stubs
8. Query Time Casts
9. Multiple Mail driver
10. New artisan Commands

New features in Laravel 7

Laravel Airlock

Laravel Airlock is a new package which provides a featherweight authentication system for single page applications, mobile applications, and simple, token based APIs. with the Airlock package a user of your application is allowed to generate multiple API tokens for their account. These tokens are able to grant abilities / scopes which specify which actions the tokens are allowed to perform.

Zttp for Http Client

Zttp is a simple Guzzle wrapper designed to provide a really pleasant development experience for most common use cases. It is a new PHP package by Adam Wathan that is a Guzzle wrapper designed to bring an expressive syntax and simplify common use cases.
I already explained about Zttp in my previous blog. You can check it out from here:
What is ZTTP and How to use it 

Cross-Origin Resource Sharing (CORS) Support

CORS support was contributed by Barry vd. Heuvel.

Laravel can automatically respond to CORS OPTION requests with values that you configure. All CORS settings may be configured in your CORS configuration file and OPTIONS requests will automatically be handled by the HandleCors middleware that is included by default in your global middleware stack.

Fluent String Operations

Laravel 7 now offers a more object-oriented, fluent string manipulation library built on top of these functions. Previously, llluminate\Support\str class was there, which provides a variety of helpful string manipulation functions.

But Now, you can create a fluent llluminate\Support\Striangable object using the Str::of method. A variety of methods may then be chained onto the object to manipulate the string:

Custom Eloquent CastClasses

Classes that implement this interface must define a get and set methods. The get method is responsible for transforming a raw value from the database into a cast value, while the set method should transform a cast value into a raw value that can be stored in the database. As an example, we will re-implement the built-in json cast type as a custom cast type:

Blade X

Laravel 7 brought to you the all new first party feature of Blade X package. This package provides an easy way to render custom HTML components in your Blade views.
Previously, you were supposed to write like this:

But, Now with the blade-X you can write it like this:

Customisable Stubs

In order to customize stub files, you need to publish them:

After running this command, a new directory will be added in your project.

Query Time Casts

Query time casting was contributed by Matt Barlow.

Sometimes you may need to apply casts while executing a query, such as when selecting a raw value from a table. For example, consider the following query:

The last_posted_at attribute on the results of this query will be a raw string. It would be convenient if we could apply a date cast to this attribute when executing the query. To accomplish this, we may use the withCasts method provided by Laravel 7:

Multiple Mail driver

Laravel 7 allows the configuration of multiple “mailers” for 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.

Source:
 Laravel 7
 Laravel 6
What is Zttp

 

. . .

Comment

Add Your Comment

Be the first to comment.

css.php