Laravel 9.4 Released | Laravel News

The Laravel team released 9.4 with the ability to override CSRF cookies, a Str::lcfirst() method, an optional retry mechanism for queued mailables, and more:

Allow VerifyCsrfToken’s CSRF cookie to be extended

@jaggy contributed the ability to override the VerifyCsrfToken by defining a newCookie method on an application’s extended CSRF middleware:

1class VerifyCsrfToken extends Middleware {

2 protected function newCookie($request, $config)

3 {

4 return new Cookie(

5 "XSRF-TOKEN-{$request->user()->type}",

6 $request->session()->token(),

7 $this->availableAt(60 * $config['lifetime']),

8 $config['path'],

9 $config['domain'],

10 $config['secure'],

11 false,

12 false,

13 $config['same_site'] ?? null,

14 );

15 }


While most applications won’t need to override the default behavior, the PR author provides the following use-case:

There are some cases in multi-tenant systems that the user might want to change the CSRF token name to prevent 419 errors. Multiple Auth providers make this happen as well mainly in XHR requests. This also allows multi-tenant systems to update the token’s domain (ie, pull the current tenant’s custom domain) from the middleware layer.

I think this is going to help a lot with people using Inertia to allow customization in how XSRF-TOKEN is named by adding the tenant ID, or even the user type.

Add soleValue method to query builders

Matthew Hailwood contributed a new soleValue() method to query builders to return a column from the sole value instead of the whole record:

1// bails if there is not exactly one result,

2// but returns an object



5// returns just the value, but no safety around

6// there being exactly one result



9// To get the ID, we must do


This update allows the following usage:

1// bails if there is not exactly one result,

2// but returns an object



5// returns just the value, but no safety around

6// there being exactly one result



9// Bails if there is not exactly one result

10// and returns just the value


Add String lcfirst() Method

Vincent Prat contributed a lcfirst() method to the Str and Stringable classes, which also supports non-ASCII characters:

1Str::lcfirst('Laravel'); // laravel

2Str::lcfirst('Laravel framework'); // laravel framework

3Str::lcfirst('Мама'); // мама

4Str::lcfirst('Мама мыла раму'); // мама мыла раму

Add “Mutex” column to schedule:list command

@madman-81 contributed a Has Mutex column to the schedule:list command, indicating if a mutex blocks a command. Issue #41311 explains how this column can help debug any scheduler issues:

Today I ran into an issue with a scheduled task that wasn’t running. It took me a while to figure out was going on, mostly because the schedule:list showed nothing out of the ordinary and was updating the “Next Due” timestamp as expected. However the tasks wasn’t executed. Long story shot, the tasks got stuck because a mutex wasn’t cleared, probably because of an unscheduled server reboot.

Here’s an example of the output based outlined in the above issue:

1$ php artisan schedule:list


3| Command | Interval | Description | Next Due | Has Mutex |


5| '/usr/bin/php8.0' 'artisan' mycommands:something | */2 * * * * | Process something | 2022-03-03 10:22:00 +00:00 | Yes |

6| '/usr/bin/php8.0' 'artisan' mycommands:otherthing | */2 * * * * | Process otherthing | 2022-03-03 10:22:00 +00:00 | |


Support for Modifying a char Column Type

Hafez Divandari contributed the ability to modify a char column type:

1Schema::table('users', function (Blueprint $table) {

2 $table->char('name', 50)->nullable()->change();


[The] doctrine/dbal package actually supports modifying char column types as StringType::class by setting fixed option to true.

So this PR, maps Laravel char to its Doctrine equivalent string type and set fixed option to true that finally gets the SQL snippet to declare a CHAR column .

Retry Mechanism for Queued Mailables

MaxGiting contributed the ability to specify a retryUntil() method or timeoutAt property to queued mailables. Check out Pull Request #41393 for more details.

Release Notes

You can see the complete list of new features and updates below and the diff between 9.3.0 and 9.4.0 on GitHub. The following release notes are directly from the changelog:



  • Support modifying a char column type (#41320)
  • Add “Mutex” column to ‘schedule:list’ command (#41338)
  • Allow eloquent whereNot() and orWhereNot() to work on column and value (#41296)
  • Allow VerifyCsrfToken’s CSRF cookie to be extended (#41342)
  • Added soleValue() to query builder (#41368)
  • Added lcfirst() to Str and Stringable (#41384)
  • Added retryUntil method to queued mailables (#41393)


  • Fixed middleware sorting for authenticating sessions (50b46db)
  • Fixed takeUntilTimeout method of LazyCollection (#41354, #41370)
  • Fixed directory for nested markdown files for mailables (#41366)
  • Prevent serializing default values of queued jobs (#41348)
  • Fixed get() and head() in Illuminate/Http/Client/PendingRequest.php (a54f481)


  • Don’t use global tap helper (#41326)
  • Allow chaining of Illuminate/Console/Concerns/InteractsWithIO::newLine (#41327)
  • set destinations since bcc missing from raw message in Mail SesTransport (8ca43f4)

Source link


Leave a Reply

Your email address will not be published. Required fields are marked *