Laravel Version 9.2 Released — What All Are New?
Laravel 9.2 is the new version of the framework that was recently released with several updates that favor developers. Laravel is a PHP-based web framework that uses substantial and elegant syntaxes to develop high-end online applications.
The Laravel package includes a powerful set of tools as well as application architecture which is a boon to any seasoned custom software development company. Furthermore, it incorporates many aspects of technologies like ASP.NET MVC, CodeIgniter, Ruby on Rails, and many others that aid in Laravel development.
This framework is free and open source. It aids developers by saving significant time and reducing the amount of thought and preparation required to create a whole website from scratch.
And we’ll be exploring more about the newer version — Laravel 9.2 through this blog. Let’s get on with it.
A Brief on Laravel
Laravel is a web application framework that features expressive, elegant syntax. It transforms development into a joyful and creative activity that is extremely rewarding. The Laravel package aims to make development easier by simplifying typical activities performed in the majority of online applications, such as authentication, routing, sessions, and caching.
Laravel promises to make the development process more enjoyable for developers while maintaining application functionality. It tries to incorporate the top features of existing web frameworks for an effective Laravel development process. Frameworks written in other languages, such as Ruby on Rails, ASP.NET MVC, and Sinatra, are examples of this.
Laravel is simple to use while still giving the sophisticated features required for big, comprehensive applications. A fantastic inversion of control container, expressive migration system, and tightly integrated unit testing support provide you with the tools you need to develop any application with which you are assigned.
The Shift in Laravel Version Releases
With the release of Laravel 8, Laravel shifted to annual releases. Before this, major versions were issued every six months. This transformation is meant to reduce the Laravel development community’s maintenance load while also challenging the development team to launch great, powerful new features while avoiding breaking updates.
Hence, a range of significant enhancements to Laravel 8 was introduced while maintaining backwards compatibility, such as parallel testing support, better Breeze starting kits, HTTP client improvements, and even new Eloquent relationship types like “has one of many”
As a result of this dedication to shipping significant new features in the current Laravel package release, future “major” releases will most likely be largely utilized for “maintenance” chores. This could mean updating upstream dependencies (as seen by the release notes).
Laravel 9 builds on Laravel 8.x by adding support for Symfony 6.0 components, Symfony Mailer, Flysystem 3.0, improved route:list output, a Laravel Scout database driver, new Eloquent accessor / mutator syntax, implicit route bindings via Enums, and diverse other bug fixes and usability enhancements.
The Laravel team published version 9.2.0, which includes an array keyBy function, an Eloquent attribute static constructor, and the integration of the Laravel CORS package into the framework, among many other things:
1. Attribute Make Method
A static constructor function to the Eloquent Attribute class, which gives the following convenience for Laravel development:
2. Array keyBy Method
An Arr::keyBy() method that functions similarly to the collection keyBy() method was added to Laravel 9.2:
3. Expects Output to Contain Test Assertion
A test method called expectsOutputToContain asserts that artisan commands include a substring of output:
4. When using Mail::alwaysTo, include X headers
When utilizing the Mail::alwaysTo() function in Laravel development, you can include X headers as follows:
The original To, Cc, and Bcc are lost when using Mail::alwaysTo in development environments. This makes it challenging to establish where the email was heading during testing.
This PR inserts the original to, cc, and bcc addresses into the email’s X-Headers so that this information may be accessed while still preventing the email from being forwarded to these recipients.
This is handy for testing the to, cc, and bcc fields while only sending emails to the provided alwaysTo address. For further information, see Pull Request #41101.
5. Laravel CORS Integration into the Framework
The fruitcake/laravel-cors package has been migrated into the Laravel framework:
The primary purpose is to reduce a circular dependency on which we rely, in addition to eliminating another skeletal dependency via Laravel 9.2.
6. String “Between First” Method
A betweenFirst() function that returns the shortest feasible segment of a string between two provided values:
7. Allow a Custom Message to be Specified for Rule Objects
When validating using a Rule object, you may give a custom error message. You may now add a custom message to the messages array with Laravel 9.2:
New Additions in Laravel 9.2
Apart from the above, the other newly added updates to Laravel 9.2 are:
- Added Illuminate/Database/Eloquent/Casts/Attribute::make() (#41014)
- Added Illuminate/Collections/Arr::keyBy() (#41029)
- Added expectsOutputToContain to the PendingCommand. (#40984)
- Added ability to supply HTTP client methods with JsonSerializable instances (#41055)
- Added Illuminate/Filesystem/AwsS3V3Adapter::getClinet() (#41079)
- Added Support for enum in Builder::whereRelation (#41091)
- Added X headers when using Mail::alwaysTo (#41101)
- Added of support Bitwise operators in query (#41112)
- Integrate Laravel CORS into framework (#41137)
- Added Illuminate/Support/Str::betweenFirst() (#41144)
- Allow specifiying custom messages for Rule objects (#41145)
Benefits of Using Laravel
When creating a web application using the Laravel package, you will benefit from the following features:
- The Laravel framework makes the web application more scalable
- Since Laravel development reuses components from various frameworks in developing web applications, significant time is saved in designing the web application
- It comprises namespaces and interfaces, which aid in resource organization and management
These are the new features and updates brought by Laravel 9.2 which will undoubtedly be of great use to developers. It’s now your chance to test and learn them to put it into practice by developing real-world projects until you’ve mastered it. And if you are a bit short on the expertise you could always partner with a credible and proficient custom software development company.
Originally published at https://www.bridge-global.com on 09 March, 2022