HTTP Query Method Support in Laravel 13.19

Published on by

HTTP Query Method Support in Laravel 13.19 image

Laravel 13.19.0 rounds out support for the HTTP QUERY method across the HTTP client and testing helpers, and adds a handful of collection, string, and queue improvements alongside the usual fixes.

  • Http::query() client method for sending QUERY requests
  • query() and queryJson() HTTP testing helpers
  • reduceInto() collection method for mutating an accumulator
  • counted() helper on Str and Stringable
  • Bulk SQS dispatch via SendMessageBatch, plus reserved-job inspection on the queue fake

What's New

Http::query() Client Method

The HTTP client gains a query() method for issuing requests with the HTTP QUERY verb, which carries its parameters in the request body rather than the URL. It mirrors the existing post(), put(), and patch() methods, sending JSON by default or form-encoded data when you call asForm().

$response = Http::query('https://api.example.com/search', [
'filter' => ['status' => 'active'],
]);

Existing URL query handling is unchanged: withQueryParameters() and the $query argument to get() continue to work as before. See #60663.

query() and queryJson() Testing Helpers

To match the client-side addition, the test suite gains query() and queryJson() helpers for exercising routes that respond to QUERY. They mirror verb-specific methods like delete() and deleteJson(), placing the test data in the request body.

Route::match(['QUERY'], '/search', fn () => request()->input('filter'));
 
$this->queryJson('/search', ['filter' => 'active'])->assertOk();

See #60662.

reduceInto() Collection Method

reduceInto() is a variant of reduce() for cases where you mutate an accumulator in place instead of returning a new value each iteration. The callback receives the accumulator and the current item, and its return value is ignored, so object accumulators need no return:

$stats = $orders->reduceInto(new OrderStats, function ($stats, $order) {
$stats->total += $order->amount;
$stats->count++;
$stats->largest = max($stats->largest, $order->amount);
});

For array or scalar accumulators, take the accumulator by reference:

$tagsMap = $posts->reduceInto([], function (&$map, $post) {
$post->tags->each(fn ($tag) => $map[$tag][] = $post->title);
});

See #60651.

counted() String Helper

Str::counted() and its Stringable equivalent pluralize a word and prepend the count in one call, a shorthand for plural($count, prependCount: true):

str('order')->counted(1); // "1 order"
str('order')->counted(2); // "2 orders"

See #60649.

Queue Improvements

Bulk SQS dispatches now go out through the SendMessageBatch API instead of one call per job, cutting the number of requests when pushing many jobs at once (#60645). The queue fake can now inspect reserved jobs, so tests can assert on jobs that have been picked up but not yet completed (#60644).

Other Fixes and Improvements

  • Pass deletedAtColumn through to assertSoftDeleted() and assertNotSoftDeleted() (#60657)
  • Allow mail config options to be defined without a name (#60668)
  • Terminate the default style value with a semicolon in ComponentAttributeBag::merge() (#60665)
  • Added tests for relative date where clauses and the date rule's past/future methods (#60675, #60687)

References

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
Acquaint Softtech

Hire Laravel developers with AI expertise at $20/hr. Get started in 48 hours.

Visit Acquaint Softtech
Acquaint Softtech logo

Acquaint Softtech

Acquaint Softtech offers AI-ready Laravel developers who onboard in 48 hours at $3000/Month with no lengthy sales process and a 100 percent money-back guarantee.

Acquaint Softtech
Laravel Cloud logo

Laravel Cloud

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

Laravel Cloud
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
No Compromises logo

No Compromises

Joel and Aaron, the two seasoned devs from the No Compromises podcast, are now available to hire for your Laravel project. ⬧ Flat rate of $9500/mo. ⬧ No lengthy sales process. ⬧ No contracts. ⬧ 100% money back guarantee.

No Compromises
Tinkerwell logo

Tinkerwell

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

Tinkerwell
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
PhpStorm logo

PhpStorm

The go-to PHP IDE with extensive out-of-the-box support for Laravel and its ecosystem.

PhpStorm
Shift logo

Shift

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

Shift
Kirschbaum logo

Kirschbaum

Providing innovation and stability to ensure your web application succeeds.

Kirschbaum
Lucky Media logo

Lucky Media

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

Lucky Media

The latest

View all →
Ship AI with Laravel: I Tricked My Own AI Into Leaking Everything image

Ship AI with Laravel: I Tricked My Own AI Into Leaking Everything

Read article
Laravel MPP: Charge AI Agents for API Access with 402 Payment Required image

Laravel MPP: Charge AI Agents for API Access with 402 Payment Required

Read article
What's missing from your PHP development environment image

What's missing from your PHP development environment

Read article
EnvKit: A Local Development Stack for Laravel on Windows and macOS image

EnvKit: A Local Development Stack for Laravel on Windows and macOS

Read article
A Copy/Paste Detector CLI for PHP 8.5+ image

A Copy/Paste Detector CLI for PHP 8.5+

Read article
Commune: A Private Community for Founders and Builders image

Commune: A Private Community for Founders and Builders

Read article