Upgrade Laravel 8

Why you should upgrade Laravel 8 to Laravel 9

Laravel is an open-source, free PHP (a general-purpose scripting language) network first released in 2011. Its stability, sophistication, and scalability makes it popular amongst PHP developers and web and app development companies

Usually, Laravel releases new updates every 6 months, but there has been much frustration amongst the development community about the reason for such constant updates. Laravel 9 was originally supposed to have been released in September 2021 but was postponed and finally released in February 2022.

What’s new in Laravel 9?

There are plenty of benefits to online business when upgrading to Laravel 9 from 8.

The change to the update frequency will be a celebration amongst the Laravel community. Current users of Laravel 8 can now take advantage of parallel testing. The practice of updates every six months has been discontinued and new updates will only be released annually.

This change will lighten the development burden on Laravel developers, users and creators. Laravel itself will also be able to introduce exciting new features with greater stability without compromising on backward compatibility. Users, developers, and businesses will all benefit from less frequent, but more robust, updates.

Key Features of Laravel 8

1. Eloquent ORM

Laravel 8 offered an Eloquent Object-Relational Mapping. This feature allowed developers to resolve database queries more easily with PHP syntax rather than writing SQL code. Of all the PHP frameworks available, ORM is the fastest. This feature meant that with Laravel 8, users could store in-memory object data in relational databases.

2. Artisan CLI

Laravel 8 gave users an Artisan Command Line Interface to create or modify any part of Laravel through the command line rather than navigate through thousands of files or folders. In addition, interaction with the database could be done directly using Laravel Tinker so there was no need to install a database client.

3. MVC Architecture

The Laravel 8 framework implemented Model View Controller architecture to improve the language relatability and adaptability at the same time following best web development practices whilst making constant improvements. The fact that MVC is also the foundation of other familiar frameworks meant that developers were one step ahead when building with Laravel.

4. Automatic Pagination

Automatic pagination in Laravel 8 reduced a developer’s time and effort and is one of the reasons Laravel has been so popular amongst the community.  App development project has been plagued in the past with issues around pagination, so this was a welcomed feature.

5. Security

Laravel 8 followed the Open Web Application Security Project (OWASP) security principles. These security features could handle threats like cross-site forgery requests to SQL injection.

New Features in Laravel 9

Laravel 9 builds on the success of Laravel 8.

1. Minimum PHP Requirements

Laravel 9 requires PHP 8 and PHP Unit 8 for testing purposes. This is because Laravel 9 employs the latest Symphony v6.0 which also requires PHP 8. Right from JIT compile to constructor property promotion, PHP 8 is a major update with notable improvements so upgrading to PHP 8 is a necessity before the move to Laravel 9.

2. Anonymous Stub Migration

With Laravel 9, developers can set anonymous stub migration as the default behaviour while running the popular migration command.

This is a key benefit. When a database is created from scratch, numerous migrations with the same class name can create problems. With the anonymous stub migration feature, issues related to class name collisions are eradicated instantly.

3. New Query Builder Interface

With the release of Laravel 9, developers use the new query builder interface for type hinting, refactoring, and static analysis. Type hinting will become necessary for refactoring, static analysis, and code completion in Integrated Development Environments.

Key Development Changes in Laravel 9

Flysystem 2

Laravel 9 has migrated from Flysystem 1 to 2 so now has an improved version of the record manipulation strategies given by the Capacity facade.

Symfony Mailer

Laravel 9 has moved from SwiftMailer (which is no longer kept up to date) to Symfony Mailer.

Custom Casts & Null

In previous versions of Laravel, the set strategy of custom cast classes was not invoked when the cast attribute was set to null. This has now been updated.

Default HTTP Client Timeout

The HTTP client now includes a default timeout of 30 seconds for situations such as the server not responding and requests hanging. A longer timeout for a specifc request can also be requested.

The Lang Directory

In Laravel 9, the resources/lang directory is now located within the root project directory (lang).

So why move from Laravel 8 to 9? Laravel 9 is certainly a progression forward from Laravel 8. Loved by the Laravel developer community, the latest version will make this framework even more popular. It provides better security, greater simplicity, and an enhanced interface.