Laravel Cloud is here! Zero-config managed infrastructure for Laravel apps. Deploy now.

Laravel 9.38 Released

Published on by

Laravel 9.38 Released image

Never Miss a Laravel Release 🚀

Sign up and get an email with each new Laravel release

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.

namespace App\Console\Commands;
 
use Illuminate\Console\Command;
use Illuminate\Contracts\Console\Isolatable;
 
class SendEmails extends Command implements Isolatable
{
// ...
}

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:

php 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():

$ php artisan tinker
 
>>> Str::slug('500$ bill');
=> "500-bill"
 
>>> Str::slug(
... title: '500$ bill',
... dictionary: ['@' => 'at', '$' => 'dollar']
... );
=> "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:

public function middleware($notifiable, $channel)
{
if ($notifiable instance of User && $notifiable->isAdmin()) {
return [];
}
 
if ($channel == 'email') {
return [new RateLimited('mailgun')];
}
 
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:

$model->touchQuietly();

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.

$router->removeMiddlewareFromGroup(
'web',
'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:

v9.38.0

Added

  • 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

  • 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)

Changed

  • 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)
Paul Redmond photo

Staff writer at Laravel News. Full stack web developer and author.

Cube

Laravel Newsletter

Join 40k+ other developers and never miss out on new tips, tutorials, and more.

image
Curotec

Curotec helps software teams hire the best Laravel developers in Latin America. Click for rates and to learn more about how it works.

Visit Curotec
Curotec logo

Curotec

World class Laravel experts with GenAI dev skills. LATAM-based, embedded engineers that ship fast, communicate clearly, and elevate your product. No bloat, no BS.

Curotec
Bacancy logo

Bacancy

Supercharge your project with a seasoned Laravel developer with 4-6 years of experience for just $3200/month. Get 160 hours of dedicated expertise & a risk-free 15-day trial. Schedule a call now!

Bacancy
Tinkerwell logo

Tinkerwell

The must-have code runner for Laravel developers. Tinker with AI, autocompletion and instant feedback on local and production environments.

Tinkerwell
Cut PHP Code Review Time & Bugs into Half with CodeRabbit logo

Cut PHP Code Review Time & Bugs into Half with CodeRabbit

CodeRabbit is an AI-powered code review tool that specializes in PHP and Laravel, running PHPStan and offering automated PR analysis, security checks, and custom review features while remaining free for open-source projects.

Cut PHP Code Review Time & Bugs into Half with CodeRabbit
Get expert guidance in a few days with a Laravel code review logo

Get expert guidance in a few days with a Laravel code review

Expert code review! Get clear, practical feedback from two Laravel devs with 10+ years of experience helping teams build better apps.

Get expert guidance in a few days with a Laravel code review
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Shift logo

Shift

Running an old Laravel version? Instant, automated Laravel upgrades and code modernization to keep your applications fresh.

Shift
Harpoon: Next generation time tracking and invoicing logo

Harpoon: Next generation time tracking and invoicing

The next generation time-tracking and billing software that helps your agency plan and forecast a profitable future.

Harpoon: Next generation time tracking and invoicing
Lucky Media logo

Lucky Media

Get Lucky Now - the ideal choice for Laravel Development, with over a decade of experience!

Lucky Media
Lunar: Laravel E-Commerce logo

Lunar: Laravel E-Commerce

E-Commerce for Laravel. An open-source package that brings the power of modern headless e-commerce functionality to Laravel.

Lunar: Laravel E-Commerce
SaaSykit: Laravel SaaS Starter Kit logo

SaaSykit: Laravel SaaS Starter Kit

SaaSykit is a Multi-tenant Laravel SaaS Starter Kit that comes with all features required to run a modern SaaS. Payments, Beautiful Checkout, Admin Panel, User dashboard, Auth, Ready Components, Stats, Blog, Docs and more.

SaaSykit: Laravel SaaS Starter Kit

The latest

View all →
Laravel Deadlock: Manage Technical Debt with Expiring Code Markers image

Laravel Deadlock: Manage Technical Debt with Expiring Code Markers

Read article
Filament v5 Released With Livewire v4 Support and a New Blueprint Tool image

Filament v5 Released With Livewire v4 Support and a New Blueprint Tool

Read article
Async Request Cancellation Updates in Inertia v2.3.10 image

Async Request Cancellation Updates in Inertia v2.3.10

Read article
FluentVox: AI Text-to-Speech for Laravel with Voice Cloning and GPU Acceleration image

FluentVox: AI Text-to-Speech for Laravel with Voice Cloning and GPU Acceleration

Read article
Laravel Boost v1.8.10 Released With New AI Prompts and Livewire v4 Support image

Laravel Boost v1.8.10 Released With New AI Prompts and Livewire v4 Support

Read article
Statamic 6 Beta Now Available image

Statamic 6 Beta Now Available

Read article