Wednesday, May 18th, 2022

What’s new in Laravel 9 – a deep dive into upcoming major releases

Laravel has been one of the most popular PHP frameworks for many years now. It’s elegant, scalable, has become one of Actually Framework for developers and companies working with PHP. Now, Laravel 9 is about to come with lots of new features.

In the past, there have been new releases every six months, resulting in a fair amount of questions, harsh comments, and confusion about Laravel’s new release process. With the release of Laravel 9, the framework has moved into a 12-month major release cycle and will be released in January 2022.

This article explores the key features of Laravel 9. In addition, we will also explain in detail how to upgrade to Laravel 9 and start developing web apps.

What is Laravel?

Laravel is an open-source PHP web application framework known for its elegant syntax. It is an MVC framework for building simple to complex web applications using the PHP programming language, and it strictly follows the MVC (Model-View-Controller) architectural pattern.

If you haven’t used Laravel, you can read about Laravel and check out our list of excellent Laravel tutorials to get you started.

Laravel 9 is on the way, and lots of new features are available to explore Learn more in this guide ️click to tweet

Main features of Laravel

If you are new to this framework, we have curated some of the best Laravel features to give you a better understanding.

Features of Laravel in Bubbles. (image source: Moon Technolabs)

eloquent orm

The Object-Relational Mapper (ORM) for Laravel is called Eloquent, and is one of the best features of Laravel as it allows seamless interaction with the data model and database of choice.

With Eloquent, Laravel removes every hurdle associated with interacting with and writing complex SQL queries to access data from your database.

artisan cli

The Artisan CLI, or command line, is another important aspect of Laravel. With it, you can create or modify any part of Laravel from the command line without having to navigate through folders and files.

With Artisan, you can also interact directly with your database using Laravel Tkinter – all without having to install a database client.

MVC Architecture

The MVC architectural nature of Laravel makes the language relatable and adaptable as it follows the prevailing web development patterns with ongoing, significant improvements.

Laravel will force you to learn and understand MVC architectural patterns, popular and used in almost all frameworks, such as AdonisJS from JavaScript and ASP.NET MVC from C#.

automatic endorsement

If you’ve ever struggled with pagination in your applications, you’ll understand the value of serializing your pagination by a built-in framework.

Laravel solves the problem of pagination by building automatic pagination that comes right out of the box. This feature is one of its most recognizable features, and it eliminates the work involved in solving the pagination mystery itself.

the protection

It is essential to check the security measures of any web application you are using, as a lack of due diligence could result in loss of funds or even hijacking of your site or product.

Laravel comes with a number of security measures due to its adherence to OWASP security principles. From cross-site request forgery (CSRF) to SQL injection, Laravel has a built-in solution for this.

Laravel 9. what to expect with

Released by September 2021, Laravel 9 has been pushed to January 2022, making it the first long-term support (LTS) release to be offered after a 12-month release cycle. This delay occurs for a variety of reasons, including but not limited to:

  1. Laravel uses varieties of community driven projects and about nine Symfony libraries. However, Symfony plans to release version 6.0 by November 2021. The delay will allow the Laravel team to include this new version of Symfony as part of Laravel 9.
  2. The delay will give the team time to monitor how Laravel interacts with the new version of Symfony for up to two months. It also gives them room to make any breaking changes or fix bugs.
  3. Ultimately, delaying the release of Laravel 9 puts the Laravel team in a better position for annual future releases. This would give the team an additional two months of ramp-up time following the release of Symphony.

For these reasons, you can see that the delay in its release is worth the wait.

Laravel 9. new features in

Now, let’s take a look at the list of features and improvements you should expect in the upcoming major release of Laravel.

Minimum PHP Requirement

First and foremost, Laravel 9 requires the latest PHP 8 and PHPUnit 8 for testing. This is because Laravel 9 will use the latest Symfony v6.0, which also requires PHP 8.

PHP 8 has significant improvements and features, from JIT compile to constructor property promotion. You can explore benchmarks for different PHP versions and learn how to upgrade to the latest PHP 8 on our blog.

Anonymous stub migration

Laravel sets anonymous stub migration to be the default behavior when you run the popular migration command:

php artisan make:migration

The anonymous stub migration feature was first released in Laravel 8.37 to solve this Github issue. The point is that multiple migrations with the same class name can cause problems when trying to recreate the database from scratch. The new stub migration feature eliminates migration class name conflicts.

Since Laravel 8.37, the framework now supports anonymous class migration files, and in Laravel 9, this will be the default behavior.

<?php

use IlluminateDatabaseMigrationsMigration;
use IlluminateDatabaseSchemaBlueprint;
use IlluminateSupportFacadesSchema;
return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('people', function (Blueprint $table)
        {
            $table->string('first_name')->nullable();
        });
    }
};

New query builder interface

With the new Laravel 9, type hinting in their IDE is highly reliable for refactoring, static analysis, and code completion. This is due to a shared interface or a lack of inheritance between QueryBuilder, EloquentBuilder, and EloquentRelation. Nevertheless, with Laravel 9, developers can now enjoy the new query builder interface for type hinting, refactoring, and static analysis.

<?php

return Model::query()
	->whereNotExists(function($query) {
		// $query is a QueryBuilder
	})
	->whereHas('relation', function($query) {
		// $query is an EloquentBuilder
	})
	->with('relation', function($query) {
		// $query is an EloquentRelation
	});

This version added new IlluminateContractsDatabaseQueryBuilder interface, As well as IlluminateDatabaseEloquentConcernsDecoratesQueryBuilder Attribute that will implement the interface in place of __call magic method.

PHP 8 String Functions

Since Laravel 9 targets PHP 8, Laravel has merged this PR, which suggests using the latest PHP 8 string functions.

These functions include the use of str_contains()handjob str_starts_with(), And str_ends_with() internally IlluminateSupportStr class.

The features and improvements of Laravel 9 listed above are just a glimpse of what’s to come. It will surely bring lots of bug fixes, features and of course many breaking changes.

Laravel 9. how to install

If you want to start playing with Laravel 9 for development and testing purposes, you can easily install and run it on your local machine.

Laravel 9 supports PHP version 8, so if you plan to test it, be sure to check your PHP version or start a fresh install.

You can find out more about the release through the packagelist.

To install Laravel 9 using Composer, run the following:

composer create-project --prefer-dist laravel/laravel laravel-9-dev dev-develop

The above command will create a new Laravel project with the project name laravel-9-dev, using the latest Laravel 9, which, as we know, is still under development (so dev-develop)

The second method is to use the Laravel global CLI to create a new Laravel project and choose to create your new project from the dev branch.

Enter the following command to create a new Laravel 9 project:

laravel new laravel-9-dev --dev

Now that you have Laravel 9 installed, you can enter the new directory (laravel-dev) and execute the artisan command to check the version:

cd laravel-9-dev
php artisan --version

This will present you with the development version of Laravel 9. Voilà!

Wondering what’s coming to Laravel 9? Let’s dive…click to tweet

Summary

Laravel is a compelling PHP framework that is gaining more attention among developers. Its upcoming major release (Laravel 9) is the first after a 12-month release cycle, and we can already see that it will introduce “juicy” new features.

Is this a complete list of new features? Probably not, as Laravel team may announce new features before release date. So make sure to bookmark this post as we will cover them in future updates.

Now its your turn! What are you looking forward to with Laravel 9? Let us know in the comments section!


Save time, cost and maximize site performance:

  • Instant help from WordPress hosting experts, 24/7.
  • Cloudflare Enterprise Integration.
  • The global audience is reached with 28 data centers across the globe.
  • Customization with our built-in application performance monitoring.

All that and more, all in one plan with no long-term contracts, assisted migration, and 30-days-money-back-guarantee. Check out our plans or talk to a salesperson to find the plan that’s right for you.

Source link