News

Interruptible Jobs in Laravel 13.7.0

Published
Interruptible Jobs in Laravel 13.7.0 image

Release updates

Never miss a Laravel release

Get an email whenever a new Laravel release lands.

Laravel v13.7.0 introduces the Interruptible interface for queued jobs to respond to worker signals, a new @fonts Blade directive for Vite font optimization, bulk JSON path assertions for testing, SortDirection enum support in collections, and several other improvements across the framework.

  • Jobs can now react to worker signals via the Interruptible interface
  • New WorkerInterrupted event for observability
  • New @fonts Blade directive and Vite font optimization runtime
  • Bulk JSON path assertions in TestResponse
  • SortDirection enum support for collections and Arr
  • Enum support for LazyCollection keyBy()
  • Various bug fixes and improvements

What's New

Jobs Can React to Worker Signals

Queued jobs can now implement the Interruptible interface to respond when a worker receives a signal like SIGTERM. This lets long-running jobs clean up or set a stop flag before the worker exits:

use Illuminate\Contracts\Queue\Interruptible;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Queue\Queueable;
 
class ReportJob implements ShouldQueue, Interruptible
{
use Queueable;
 
protected bool $stop = false;
 
public function handle(): void
{
while (! $this->stop) {
// do work...
}
}
 
public function interrupted(int $signal): void
{
$this->stop = true;
}
}

PR: #59833

New @fonts Blade Directive and Vite Font Optimization

This release adds a new @fonts Blade directive and Vite::fonts() method for rendering font preload links and inline styles. The feature reads font manifests generated by the Vite plugin and supports selective family loading.

Basic usage in your layout:

<!DOCTYPE html>
<html>
<head>
@fonts
@vite('resources/js/app.js')
</head>
<body>
{{ $slot }}
</body>
</html>

This renders preload <link> tags and an inline <style> block with all @font-face rules and CSS variables from the font manifest.

You can also filter to load only specific font families:

{{-- Load a single family --}}
@fonts('sans')
 
{{-- Load multiple families --}}
@fonts(['sans', 'mono'])

PR: #59584

Bulk JSON Path Assertions in TestResponse

The testing layer now includes assertJsonPaths() and assertJsonMissingPaths() methods for asserting multiple JSON values at once.

Before:

$response->assertJsonPath('data.id', 1)
->assertJsonPath('data.name', 'Taylor')
->assertJsonPath('meta.count', 3);

After:

$response->assertJsonPaths([
'data.id' => 1,
'data.name' => 'Taylor',
'meta.count' => 3,
]);

The companion assertJsonMissingPaths() method works the same way for asserting absent keys:

$response->assertJsonMissingPaths(['password', 'secret_token']);

PR: #59829

SortDirection Enum Support for Collections

Collections and the Arr class now support the SortDirection enum for specifying sort order, providing better type safety when sorting:

use SortDirection;
 
$sorted = $collection->sortBy('name', descending: SortDirection::Descending);

PR: #59859

Introducing WorkerInterrupted Event

A new WorkerInterrupted event is dispatched when a worker receives a signal, before it stops. This is useful for observability — you can log, alert, or call an external service when a signal arrives, even if the individual job doesn't implement Interruptible.

PR: #59848

isLocked Method Added to Lock Class

The Lock class now includes an isLocked() method to check the current lock status.

PR: #59791

Enum Support for LazyCollection keyBy()

LazyCollection::keyBy() now accepts a BackedEnum, matching the behavior already available in Collection. Previously, passing an enum would throw an error when attempting to convert it to a string.

PR: #59809

Miscellaneous Fixes and Improvements

This update includes enum support improvements across ConcurrencyManager, QueueManager, LogManager, SessionManager, and RedisManager. Various docblock improvements, type corrections, and bug fixes from community contributors are also included.

Upgrade Notes

No breaking changes are expected for typical applications. Review the changelog for PR-by-PR details when upgrading.

References

Paul Redmond photo

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

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
Laravel Image Responses: Serve Resized Images From Routes image

Laravel Image Responses: Serve Resized Images From Routes

Read article
Pause All Laravel Queues During a Deploy image

Pause All Laravel Queues During a Deploy

Read article
Laravel Terminal UI for the artisan dev Command image

Laravel Terminal UI for the artisan dev Command

Read article
Pause All Queues and a New artisan dev UI in Laravel 13.25 image

Pause All Queues and a New artisan dev UI in Laravel 13.25

Read article
Laravel monitoring that doesn't bill you by your traffic image

Laravel monitoring that doesn't bill you by your traffic

Read article
Mock PHP Classes in Tests With the Double Library image

Mock PHP Classes in Tests With the Double Library

Read article