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

masteringlaravel logo
Laravel Code Review

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

Visit Laravel Code Review

The latest

View all →
CPX: The Composer Package Executor for PHP image

CPX: The Composer Package Executor for PHP

Read article
Laravel AI SDK Adds Human-in-the-Loop Tool Approval image

Laravel AI SDK Adds Human-in-the-Loop Tool Approval

Read article
Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals image

Pest 5 Released With Test Impact Analysis, Agent Verification, and Evals

Read article
Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs image

Queue-SQL: Run Mass Deletes and Updates Across Parallel Queue Jobs

Read article
Blade Formatting in Laravel Pint image

Blade Formatting in Laravel Pint

Read article
Inertia DevTools Is Now on the Chrome Web Store image

Inertia DevTools Is Now on the Chrome Web Store

Read article