Laravel 9.38 Released | Laravel News

The Laravel team released 9.38 this week with isolated artisan commands, conditionally set notification middleware, configurable max exceptions for queueable notifications, and more.

Isolated Artisan commands

Oliver Nybroe contributed an Isolatable interface that makes it a cinch to ensure your commands only run a single process at once.

1namespace App\Console\Commands;


3use Illuminate\Console\Command;

4use Illuminate\Contracts\Console\Isolatable;


6class SendEmails extends Command implements Isolatable


8 // ...


The first artisan command to include the Isolatable interface is the artisan migrate command. Using the --isolated flag you can limit the migrate to one active process and ensures that two servers cannot run the migrate command at the same time:

1php artisan migrate --isolated

Note: isolated migrations is not the default and was released behind the --isolated flag to reduce the chance of breaking changes.

See the Isolatable Commands documentation for more details on how to use this in your commands.

Set the session store handler

Samuel Štancl contributed a setHandler method to the session Store class. The pull request description has this to say about why this can be useful:

The use case is that when you’re changing database connections on the fly, the database session driver can run into issues where it tries to run queries on a DB connection that no longer exists…By adding the setter, I can reconstruct the DatabaseSessionHandler on the fly and make it use the correct DB connection.

Slug helper dictionary

@Dhemy contributed a customizable dictionary for special characters when calling Str::slug():

1$ php artisan tinker


3>>> Str::slug('500$ bill');

4=> "500-bill"


6>>> Str::slug(

7... title: '500$ bill',

8... dictionary: ['@' => 'at', '$' => 'dollar']

9... );

10=> "500-dollar-bill"

Conditionally set notification middleware

Andrew Monty contributed the ability to set notification middleware based on the notifiable and channel instance. Here’s an example from the pull request description:

1public function middleware($notifiable, $channel)


3 if ($notifiable instance of User && $notifiable->isAdmin()) {

4 return [];

5 }


7 if ($channel == 'email') {

8 return [new RateLimited('mailgun')];

9 }


11 return [];


Add a touchQuietly model convenience method

Craig Anderson contributed a touchQuietly() convenience method to touch a model’s update timestamp without raising any events:


Remove middleware from a group

Mateus Guimarães contributed to the ability to remove middleware from a group. This feature is helpful if you need to register or remove middleware dynamically.


2 'web',

3 'test-middleware'


Queueable notifications can set max exceptions

Andrew Monty contributed the ability for queued notifications to use max exceptions. Setting max exceptions is helpful in a setting where you have many retries. Perhaps the queued notification is rate limited by a third party or otherwise not going to succeed, and you want to customize the max number of allowed exceptions.

See Pull Request #44773 for more details and examples.

Release Notes

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



  • Added Illuminate/Routing/Route::flushController() (#44393)
  • Added Illuminate/Session/Store::setHandler() (#44736)
  • Added dictionary to slug helper (#44730)
  • Added ability to set middleware based on notifiable instance and channel (#44767)
  • Added touchQuietly convenience method to Model (#44722)
  • Added Illuminate/Routing/Router::removeMiddlewareFromGroup() (#44780)
  • Allow queueable notifications to set maxExceptions (#44773)
  • Make migrate command isolated (#44743, ac3252a)


  • Fixed whenPivotLoaded(As) api resource methods when using Eloquent strict mode (#44792)
  • Fixed components view error when using $attributes in parent view (#44778)
  • Fixed problem with disregarding global scopes when using existOr and doesntExistOr methods on model query (#44795)


  • Recompiles views when necessary (#44737)
  • Throw meaningful exception when broadcast connection not configured (#44745)
  • Prevents booting of providers when running env:encrypt (#44758)
  • Added nonce for preloaded assets (#44747)
  • Inherit crossorigin attributes while preloading view (#44800)

Source link


Leave a Reply

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