Introduction

Laravel development is one of the most desirable frameworks of 2022 with clean codes and functionality. It recently released its latest version, Laravel 9.37 on Oct 26, 2022.

It features verbose view caching CLI output, strict violation handlers, and support for preloading assets with Vite. Before we dive into those elements one by one, let’s take a moment to understand how it all started, and how much the framework has improved since its inception in 2011, eleven years ago.

Journey of Laravel: From Beginning till Now

Journey of Laravel

An open-source web framework written in PHP, Laravel was created by Taylor Otwell in 2011. The idea was to provide an improved alternative to CodeIgniter, a framework that did not feature built-in support for user authentication and authorization.

  • Laravel 1, released on June 9, 2011, had built-in authentication, localization, routing, and other mechanisms. However, it did not support controllers which prevented it from being a    fully MVC framework.
  • Laravel 2 was released in 2011 itself, in September. In Laravel 2, there was support for controllers which made it a true MVC framework.
  • Lavarel 3, released in Feb 2012 added Artisan, a command line interface, a built-in DBMS support, events, and a packaging system called bundles.
  • Lavarel 4 was released in May 2013, and it was a complete rewrite. It had many new features packed with Scheduler, Flysystem, improved package handling through Elixir, and an optional Socialite for authentication simplification.
  • Laravel 5, 5.1, 5.2, 5.3, and 5.4 were released from June 2015 to Jan 2017 and took the framework to new heights. Laravel 5 introduced Lumen, which is no longer recommended by promoters. The last one in the series, 5.4, had Laravel Mix, Laravel Dus, Route improvements, High order messaging, and much more.
  • Laravel 6 was released in Sept 2019, with improved authorization responses and job middleware, and sub-query improvements. It also introduced semantic versioning and compatibility with Laravel Vapor.
  • Laravel 7 was released in March 2020 and introduced custom eloquent casts, blade component tags, Sanctum, and fluent string operations.
  • Laravel 8 was released in Sept 2020 with Laravel Jetstream, migration squashing, model factory classes, and other improvements.
  • Laravel 9, the latest version of the framework, was released in Feb 2022.

Laravel 9

Some of the notable features and notable features of Laravel 9 are listed below.

Laravel 9 requires PHP 8 for testing since it uses Symfony v6.0. PHP 8 comes with its own improvements and features. Features like JIT compile to constructor property promotion, it is a benchmark PHP version.

This also allowed Laravel 9 to use PHP 8’s string functions like str_starts_with(), str_ends_with(), and str_contains() internally in the \Illuminate\Support\Str class.

To solve the GitHub issue with multiple stub migration, Laravel 9 supports anonymous stub migration. It helps with migration class name collisions, especially when recreating the database.

With Laravel 9, the developers could enjoy type hinting, static analysis, and refactoring with the new query builder interface. Laravel 9 made type hinting highly reliable for refactoring and code completion.

What’s New In Laravel 9.37

What’s New In Laravel 9.37

The latest release of Laravel came on Oct 26, 2022, with Laravel 9.37. This framework now supports query builder raw value method, verbose view caching CLI output, handlers for silently discarded and missing attributes, and much more. Here’s each of them in detail.

Verbose View Caching

Laravel 9.37 comes with verbose view caching where developers will now have the ability to pass ‘-v’ to the ‘view:cache’ artisan command to output the directories the command is looking in. ‘-vv’ would be for seeing every file the command caches.

php artisan view:cache -vv

Strict Violation Handlers

Now, developers will have the ability to register handlers for ‘missing attributes’ and ‘silently discarded’ strict mode violations.

Model::handleMissingAttributeViolationUsing(

    function ($model, $key) {

        // …

    }

);

Model::handleDiscardedAttributeViolationUsing(

    function ($model, $keys) {

        // …

    }

);

Pass A Callable When Using ‘rescue()’

With Laravel 9.37, you can pass a callable as the ‘$report’ parameter when you use ‘rescue()’ so you can conditionally report the error depending on the boolean returned.

rescue(fn() => ‘error’, fn() => ‘rescue’, function(Throwable $e){

    return $e instanceof SomeException;

});

Preloading Assets With Vite

This feature will improve the loading speed by preloading the critical assets. It is possible with Vite, and this would be the default behavior for Laravel apps using Vite.

Get A Value From A SQL Expression

With the ‘rawValue()’ method, you can get a value from an SQL expression. Here is an example.

$first = TripModel::orderBy(‘date_at’, ‘ASC’)

    ->rawValue(‘YEAR(`date_at`)’);

$last = TripModel::orderBy(‘date_at’, ‘DESC’)

    ->rawValue(‘YEAR(`date_at`)’);

$fullname = UserModel::where(‘id’, $id)

    ->rawValue(‘CONCAT(`first_name`, ” “, `last_name`)’);

Conclusion

Laravel is an open-source PHP web framework that is ideal to build web applications because of its model–view–controller architectural pattern. With the release of Laravel 9.37, the features of the framework have been polished for the betterment. If you think Laravel is the perfect fit for your project, Infiraise is the perfect place to hire Laravel developers equipped with the latest tools and technologies to meet all your requirements.

Frequently Asked Questions

Have questions about the latest Laravel Release? We’ve got your covered.

What is Added in Laravel 9.37?

Laravel 9.37 added optional verbose output when caching, closure to rescue report parameters, Vite support for preloading critical assets, and query builder raw value method.

What has been Fixed with Laravel 9.37?

The expectations for output assertion in PendingCommand have been fixed with Laravel 9.37. Moreover, Model:show registering getAttribute() as a null accessor has also been fixed.