Skip to content

Conversation

@pelmered
Copy link
Contributor

@pelmered pelmered commented Jan 27, 2024

This adds support for the StreamedJsonResponse that was added in Symfony 6.3.

Here is the Symfony documentation for this feature:
https://symfony.com/doc/6.3/components/http_foundation.html#streaming-a-json-response

This is how it can be used in Laravel with this PR:

<?php

namespace App\Http\Controllers;

use Generator;
use App\Models\User;

class ExampleController extends Controller
{
    public function index()
    {
        return response()->streamJson([
            'users' => $this->yieldUsers(),
        ]);
    }

    protected function yieldUsers(): Generator
    {
        foreach (User::query()->cursor() as $user) {
            yield $user;
        }
    }
}

The main benefits of streamed responses is that it uses a lot less memory and can be a lot faster, especially for very large responses. You can yield data that flushes straight into the response stream and the client can start to process the data before all the data is ready and sent on the server side.

I also added a test helper:

$response->assertStreamedJsonContent([
    'data' => [
        ['id' => 1],
        ['id' => 2],
        ['id' => 3],
    ],
]);

I also added some test, but I'm not sure if they are enough.

@pelmered pelmered changed the title Add support for streamed JSON Response [10.x] Add support for streamed JSON Response Jan 27, 2024
@taylorotwell taylorotwell merged commit e9c67db into laravel:10.x Jan 29, 2024
@amcsi
Copy link

amcsi commented Feb 1, 2024

Is there some counterpart to this for reading JSON requests streamed?

@pelmered
Copy link
Contributor Author

pelmered commented Feb 2, 2024

Is there some counterpart to this for reading JSON requests streamed?

I haven't super much experience with this just yet, but I have read some theory and I am going to implement this in our application the next weeks.

Do you mean server side or client side?
PHP is not that well equipped to handle this in a good way I think. With node you can use something like stream-json and with JS on the frontend you can consume this with fetch and some additional parameters.
I can write an article about this when I have tested everything out. Maybe also add some documentation about this in the Laravel docs?

@JosephSilber
Copy link
Contributor

@pelmered In your example, what's the point of the yieldUsers method? Can the user cursor not be passed off directly?

Would this not work?

response()->streamJson([
    'users' => User::cursor(),
]);

@JosephSilber
Copy link
Contributor

Do you mean server side or client side?

PHP is not that well equipped to handle this in a good way I think.

While it seems @amcsi was asking about the client, I just want to give a shoutout to @cerbero90's excellent Lazy JSON PHP package 👌

@cerbero90
Copy link
Contributor

@JosephSilber honoured to be mentioned by the Jedi master of Lazy collections! 🙏

renovate bot referenced this pull request in RadioRoster/backend Feb 10, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
| [laravel/framework](https://laravel.com)
([source](https://github.com/laravel/framework)) | `10.33.0` ->
`10.43.0` |
[![age](https://developer.mend.io/api/mc/badges/age/packagist/laravel%2fframework/10.43.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/packagist/laravel%2fframework/10.43.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/packagist/laravel%2fframework/10.33.0/10.43.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/packagist/laravel%2fframework/10.33.0/10.43.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>laravel/framework (laravel/framework)</summary>

###
[`v10.43.0`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10430---2024-01-30)

[Compare
Source](https://github.com/laravel/framework/compare/v10.42.0...v10.43.0)

- \[10.x] Add storage:unlink command by
[@&#8203;salkovmx](https://github.com/salkovmx) in
[https://github.com/laravel/framework/pull/49795](https://github.com/laravel/framework/pull/49795)
- \[10.x] Unify `\Illuminate\Log\LogManager` method definition comments
with `\Psr\Logger\Interface` by
[@&#8203;eusonlito](https://github.com/eusonlito) in
[https://github.com/laravel/framework/pull/49805](https://github.com/laravel/framework/pull/49805)
- \[10.x] class-name string argument for global scopes by
[@&#8203;emargareten](https://github.com/emargareten) in
[https://github.com/laravel/framework/pull/49802](https://github.com/laravel/framework/pull/49802)
- \[10.x] Add `hasIndex()` and minor Schema enhancements by
[@&#8203;hafezdivandari](https://github.com/hafezdivandari) in
[https://github.com/laravel/framework/pull/49796](https://github.com/laravel/framework/pull/49796)
- \[10.x] Do not touch `BelongsToMany` relation when using
`withoutTouching` by
[@&#8203;mateusjunges](https://github.com/mateusjunges) in
[https://github.com/laravel/framework/pull/49798](https://github.com/laravel/framework/pull/49798)
- \[10.x] Check properties on mailables are initialized before sharing
with the view by [@&#8203;j3j5](https://github.com/j3j5) in
[https://github.com/laravel/framework/pull/49813](https://github.com/laravel/framework/pull/49813)
- \[10.x] Remove duplicate actions/checkout from queue workflow by
[@&#8203;Jubeki](https://github.com/Jubeki) in
[https://github.com/laravel/framework/pull/49828](https://github.com/laravel/framework/pull/49828)
- \[10.x] Add `insertOrIgnoreUsing` for Eloquent by
[@&#8203;trovster](https://github.com/trovster) in
[https://github.com/laravel/framework/pull/49827](https://github.com/laravel/framework/pull/49827)
- \[10.x] Make `hasIndex()` Order-sensitive by
[@&#8203;hafezdivandari](https://github.com/hafezdivandari) in
[https://github.com/laravel/framework/pull/49840](https://github.com/laravel/framework/pull/49840)
- \[10.x] Release action by
[@&#8203;driesvints](https://github.com/driesvints) in
[https://github.com/laravel/framework/pull/49838](https://github.com/laravel/framework/pull/49838)
- \[10.x] Add MariaDb1060Platform by
[@&#8203;driesvints](https://github.com/driesvints) in
[https://github.com/laravel/framework/pull/49848](https://github.com/laravel/framework/pull/49848)
- \[10.x] Unified Pivot and Model Doc Block `$guarded` by
[@&#8203;eusonlito](https://github.com/eusonlito) in
[https://github.com/laravel/framework/pull/49851](https://github.com/laravel/framework/pull/49851)
- \[10.x] Introducing `beforeStartingTransaction` callback and use it in
`LazilyRefreshDatabase` by
[@&#8203;pascalbaljet](https://github.com/pascalbaljet) in
[https://github.com/laravel/framework/pull/49853](https://github.com/laravel/framework/pull/49853)
- \[10.x] fix password max validation message by
[@&#8203;MrPunyapal](https://github.com/MrPunyapal) in
[https://github.com/laravel/framework/pull/49861](https://github.com/laravel/framework/pull/49861)
- \[10.x] Fix validation message used for max file size by
[@&#8203;mateusjunges](https://github.com/mateusjunges) in
[https://github.com/laravel/framework/pull/49879](https://github.com/laravel/framework/pull/49879)
- Update README.md by
[@&#8203;foremtehan](https://github.com/foremtehan) in
[https://github.com/laravel/framework/pull/49878](https://github.com/laravel/framework/pull/49878)
- \[10.x] Adds
`FormRequest[@&#8203;getRules](https://github.com/getRules)()` method
by [@&#8203;cosmastech](https://github.com/cosmastech) in
[https://github.com/laravel/framework/pull/49860](https://github.com/laravel/framework/pull/49860)
- \[10.x] add addGlobalScopes method by
[@&#8203;emargareten](https://github.com/emargareten) in
[https://github.com/laravel/framework/pull/49880](https://github.com/laravel/framework/pull/49880)
- \[10.x] Allow brick/math 0.12 by
[@&#8203;LogicSatinn](https://github.com/LogicSatinn) in
[https://github.com/laravel/framework/pull/49883](https://github.com/laravel/framework/pull/49883)
- \[10.x] Add support for streamed JSON Response by
[@&#8203;pelmered](https://github.com/pelmered) in
[https://github.com/laravel/framework/pull/49873](https://github.com/laravel/framework/pull/49873)
- \[10.x] Using the native fopen exception in LockableFile.php by
[@&#8203;eusonlito](https://github.com/eusonlito) in
[https://github.com/laravel/framework/pull/49895](https://github.com/laravel/framework/pull/49895)
- \[10.x] Fix LazilyRefreshDatabase when testing artisan commands by
[@&#8203;iamgergo](https://github.com/iamgergo) in
[https://github.com/laravel/framework/pull/49914](https://github.com/laravel/framework/pull/49914)
- \[10.x] Fix expressions in with-functions doing aggregates by
[@&#8203;tpetry](https://github.com/tpetry) in
[https://github.com/laravel/framework/pull/49912](https://github.com/laravel/framework/pull/49912)
- \[10.x] Fix redis tag entries never becoming stale if cache ttl is
past time by [@&#8203;jagers](https://github.com/jagers) in
[https://github.com/laravel/framework/pull/49864](https://github.com/laravel/framework/pull/49864)
- \[10.x] Fix - The `Translator` may incorrectly report the locale of a
missing translation key by
[@&#8203;VicGUTT](https://github.com/VicGUTT) in
[https://github.com/laravel/framework/pull/49900](https://github.com/laravel/framework/pull/49900)
- \[10.x] fix Before/After validation rules by
[@&#8203;MrPunyapal](https://github.com/MrPunyapal) in
[https://github.com/laravel/framework/pull/49871](https://github.com/laravel/framework/pull/49871)

###
[`v10.42.0`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10420---2024-01-23)

[Compare
Source](https://github.com/laravel/framework/compare/v10.41.0...v10.42.0)

- \[10.x] Switch to hash_equals in `File::hasSameHash()` by
[@&#8203;simonhamp](https://github.com/simonhamp) in
[https://github.com/laravel/framework/pull/49721](https://github.com/laravel/framework/pull/49721)
- \[10.x] fix Rule::unless for callable $condition by
[@&#8203;dbakan](https://github.com/dbakan) in
[https://github.com/laravel/framework/pull/49726](https://github.com/laravel/framework/pull/49726)
- \[10.x] Adds JobQueueing event by
[@&#8203;dmason30](https://github.com/dmason30) in
[https://github.com/laravel/framework/pull/49722](https://github.com/laravel/framework/pull/49722)
- \[10.x] Fix decoding issue in MailLogTransport by
[@&#8203;rojtjo](https://github.com/rojtjo) in
[https://github.com/laravel/framework/pull/49727](https://github.com/laravel/framework/pull/49727)
- \[10.x] Implement "max" validation rule for passwords by
[@&#8203;angelej](https://github.com/angelej) in
[https://github.com/laravel/framework/pull/49739](https://github.com/laravel/framework/pull/49739)
- \[10.x] Add multiple channels/routes to AnonymousNotifiable at once by
[@&#8203;iamgergo](https://github.com/iamgergo) in
[https://github.com/laravel/framework/pull/49745](https://github.com/laravel/framework/pull/49745)
- \[10.x] Sort service providers alphabetically by
[@&#8203;buismaarten](https://github.com/buismaarten) in
[https://github.com/laravel/framework/pull/49762](https://github.com/laravel/framework/pull/49762)
- \[10.x] Global default options for the http factory by
[@&#8203;timacdonald](https://github.com/timacdonald) in
[https://github.com/laravel/framework/pull/49767](https://github.com/laravel/framework/pull/49767)
- \[10.x] Only use `Carbon` if accessed from Laravel or also uses
`illuminate/support` by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49772](https://github.com/laravel/framework/pull/49772)
- \[10.x] Add `Str::unwrap` by
[@&#8203;stevebauman](https://github.com/stevebauman) in
[https://github.com/laravel/framework/pull/49779](https://github.com/laravel/framework/pull/49779)
- \[10.x] Allow Uuid and Ulid in Carbon::createFromId() by
[@&#8203;kylekatarnls](https://github.com/kylekatarnls) in
[https://github.com/laravel/framework/pull/49783](https://github.com/laravel/framework/pull/49783)
- \[10.x] Test Improvements by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49785](https://github.com/laravel/framework/pull/49785)

###
[`v10.41.0`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10410---2024-01-16)

[Compare
Source](https://github.com/laravel/framework/compare/v10.40.0...v10.41.0)

- \[10.x] Add a `threshold` parameter to the `Number::spell` helper by
[@&#8203;caendesilva](https://github.com/caendesilva) in
[https://github.com/laravel/framework/pull/49610](https://github.com/laravel/framework/pull/49610)
- Revert "\[10.x] Make ComponentAttributeBag Arrayable" by
[@&#8203;luanfreitasdev](https://github.com/luanfreitasdev) in
[https://github.com/laravel/framework/pull/49623](https://github.com/laravel/framework/pull/49623)
- \[10.x] Fix return value and docblock by
[@&#8203;dwightwatson](https://github.com/dwightwatson) in
[https://github.com/laravel/framework/pull/49627](https://github.com/laravel/framework/pull/49627)
- \[10.x] Add an option to specify the default path to the models
directory for `php artisan model:prune` by
[@&#8203;dbhynds](https://github.com/dbhynds) in
[https://github.com/laravel/framework/pull/49617](https://github.com/laravel/framework/pull/49617)
- \[10.x] Allow job chains to be conditionally dispatched by
[@&#8203;fjarrett](https://github.com/fjarrett) in
[https://github.com/laravel/framework/pull/49624](https://github.com/laravel/framework/pull/49624)
- \[10.x] Add test for existing empty test by
[@&#8203;lioneaglesolutions](https://github.com/lioneaglesolutions) in
[https://github.com/laravel/framework/pull/49632](https://github.com/laravel/framework/pull/49632)
- \[10.x] Add additional context to Mailable assertion messages by
[@&#8203;lioneaglesolutions](https://github.com/lioneaglesolutions) in
[https://github.com/laravel/framework/pull/49631](https://github.com/laravel/framework/pull/49631)
- \[10.x] Allow job batches to be conditionally dispatched by
[@&#8203;fjarrett](https://github.com/fjarrett) in
[https://github.com/laravel/framework/pull/49639](https://github.com/laravel/framework/pull/49639)
- \[10.x] Revert parameter name change by
[@&#8203;timacdonald](https://github.com/timacdonald) in
[https://github.com/laravel/framework/pull/49659](https://github.com/laravel/framework/pull/49659)
- \[10.x] Printing Name of The Method that Calls
`ensureIntlExtensionIsInstalled` in `Number` class. by
[@&#8203;devajmeireles](https://github.com/devajmeireles) in
[https://github.com/laravel/framework/pull/49660](https://github.com/laravel/framework/pull/49660)
- \[10.x] Update pagination tailwind.blade.php by
[@&#8203;anasmorahhib](https://github.com/anasmorahhib) in
[https://github.com/laravel/framework/pull/49665](https://github.com/laravel/framework/pull/49665)
- \[10.x] feat: add base argument to Stringable->toInteger() by
[@&#8203;adamczykpiotr](https://github.com/adamczykpiotr) in
[https://github.com/laravel/framework/pull/49670](https://github.com/laravel/framework/pull/49670)
- \[10.x]: Remove unused class ShouldBeUnique when make a job by
[@&#8203;Kenini1805](https://github.com/Kenini1805) in
[https://github.com/laravel/framework/pull/49669](https://github.com/laravel/framework/pull/49669)
- \[10.x] Add tests for Eloquent methods by
[@&#8203;milwad-dev](https://github.com/milwad-dev) in
[https://github.com/laravel/framework/pull/49673](https://github.com/laravel/framework/pull/49673)
- Implement draft workflow by
[@&#8203;driesvints](https://github.com/driesvints) in
[https://github.com/laravel/framework/pull/49683](https://github.com/laravel/framework/pull/49683)
- \[10.x] Fixing Types, Word and Returns of `Number`class. by
[@&#8203;devajmeireles](https://github.com/devajmeireles) in
[https://github.com/laravel/framework/pull/49681](https://github.com/laravel/framework/pull/49681)
- \[10.x] Test Improvements by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49679](https://github.com/laravel/framework/pull/49679)
- \[10.x] Officially support floats in trans_choice and
Translator::choice by
[@&#8203;philbates35](https://github.com/philbates35) in
[https://github.com/laravel/framework/pull/49693](https://github.com/laravel/framework/pull/49693)
- \[10.x] Use static function by
[@&#8203;michaelnabil230](https://github.com/michaelnabil230) in
[https://github.com/laravel/framework/pull/49696](https://github.com/laravel/framework/pull/49696)
- \[10.x] Revert "\[10.x] Improve numeric comparison for custom casts"
by [@&#8203;driesvints](https://github.com/driesvints) in
[https://github.com/laravel/framework/pull/49702](https://github.com/laravel/framework/pull/49702)
- \[10.x] Add exit code to queue:clear, and queue:forget commands by
[@&#8203;bytestream](https://github.com/bytestream) in
[https://github.com/laravel/framework/pull/49707](https://github.com/laravel/framework/pull/49707)
- \[10.x] Allow StreamInterface as raw HTTP Client body by
[@&#8203;janolivermr](https://github.com/janolivermr) in
[https://github.com/laravel/framework/pull/49705](https://github.com/laravel/framework/pull/49705)

###
[`v10.40.0`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10400---2024-01-09)

[Compare
Source](https://github.com/laravel/framework/compare/v10.39.0...v10.40.0)

- \[10.x] `Model::preventAccessingMissingAttributes()` raises exception
for enums & primitive castable attributes that were not retrieved by
[@&#8203;cosmastech](https://github.com/cosmastech) in
[https://github.com/laravel/framework/pull/49480](https://github.com/laravel/framework/pull/49480)
- \[10.x] Include system versioned tables for MariaDB by
[@&#8203;hafezdivandari](https://github.com/hafezdivandari) in
[https://github.com/laravel/framework/pull/49509](https://github.com/laravel/framework/pull/49509)
- \[10.x] Fixes the `Arr::dot()` method to properly handle indexes array
by [@&#8203;kayw-geek](https://github.com/kayw-geek) in
[https://github.com/laravel/framework/pull/49507](https://github.com/laravel/framework/pull/49507)
- \[10.x] Expand Gate::allows & Gate::denies signature by
[@&#8203;antonkomarev](https://github.com/antonkomarev) in
[https://github.com/laravel/framework/pull/49503](https://github.com/laravel/framework/pull/49503)
- \[10.x] Improve numeric comparison for custom casts by
[@&#8203;imahmood](https://github.com/imahmood) in
[https://github.com/laravel/framework/pull/49504](https://github.com/laravel/framework/pull/49504)
- \[10.x] Add session except method by
[@&#8203;xurshudyan](https://github.com/xurshudyan) in
[https://github.com/laravel/framework/pull/49520](https://github.com/laravel/framework/pull/49520)
- \[10.x] Add `Number::clamp` by
[@&#8203;jbrooksuk](https://github.com/jbrooksuk) in
[https://github.com/laravel/framework/pull/49512](https://github.com/laravel/framework/pull/49512)
- \[10.x] Fix Schedule test by
[@&#8203;michaelnabil230](https://github.com/michaelnabil230) in
[https://github.com/laravel/framework/pull/49538](https://github.com/laravel/framework/pull/49538)
- \[10.x] Use correct format of date by
[@&#8203;buismaarten](https://github.com/buismaarten) in
[https://github.com/laravel/framework/pull/49541](https://github.com/laravel/framework/pull/49541)
- \[10.x] Clean Arr by
[@&#8203;michaelnabil230](https://github.com/michaelnabil230) in
[https://github.com/laravel/framework/pull/49530](https://github.com/laravel/framework/pull/49530)
- \[10.x] Make ComponentAttributeBag Arrayable by
[@&#8203;iamgergo](https://github.com/iamgergo) in
[https://github.com/laravel/framework/pull/49524](https://github.com/laravel/framework/pull/49524)
- \[10.x] Fix whenAggregated when default is not specified by
[@&#8203;lovePizza](https://github.com/lovePizza) in
[https://github.com/laravel/framework/pull/49521](https://github.com/laravel/framework/pull/49521)
- \[10.x] Update AsArrayObject.php to use ARRAY_AS_PROPS flag by
[@&#8203;pintend](https://github.com/pintend) in
[https://github.com/laravel/framework/pull/49534](https://github.com/laravel/framework/pull/49534)
- \[10.x] Remove invalid `RedisCluster::client()` call by
[@&#8203;tillkruss](https://github.com/tillkruss) in
[https://github.com/laravel/framework/pull/49560](https://github.com/laravel/framework/pull/49560)
- \[10.x] Remove unused code from `PhpRedisConnector` by
[@&#8203;tillkruss](https://github.com/tillkruss) in
[https://github.com/laravel/framework/pull/49559](https://github.com/laravel/framework/pull/49559)
- \[10.x] Flush about command during test runs by
[@&#8203;timacdonald](https://github.com/timacdonald) in
[https://github.com/laravel/framework/pull/49557](https://github.com/laravel/framework/pull/49557)
- \[10.x] Fix parentOfParameter method by
[@&#8203;iamgergo](https://github.com/iamgergo) in
[https://github.com/laravel/framework/pull/49548](https://github.com/laravel/framework/pull/49548)
- \[10.x] Make the Schema Builder macroable by
[@&#8203;kevinb1989](https://github.com/kevinb1989) in
[https://github.com/laravel/framework/pull/49547](https://github.com/laravel/framework/pull/49547)
- \[10.x] Remove unused code from tests by
[@&#8203;imahmood](https://github.com/imahmood) in
[https://github.com/laravel/framework/pull/49566](https://github.com/laravel/framework/pull/49566)
- \[10.x] Update Query/Builder.php $columns typehint by
[@&#8203;Grldk](https://github.com/Grldk) in
[https://github.com/laravel/framework/pull/49563](https://github.com/laravel/framework/pull/49563)
- \[10.x] Add assertViewEmpty to TestView by
[@&#8203;dwightwatson](https://github.com/dwightwatson) in
[https://github.com/laravel/framework/pull/49558](https://github.com/laravel/framework/pull/49558)
- \[10.x] Update tailwind.blade.php for dark mode by
[@&#8203;sabinchacko03](https://github.com/sabinchacko03) in
[https://github.com/laravel/framework/pull/49515](https://github.com/laravel/framework/pull/49515)
- \[10.x] Fix deprecation with null value in cache FileStore by
[@&#8203;driesvints](https://github.com/driesvints) in
[https://github.com/laravel/framework/pull/49578](https://github.com/laravel/framework/pull/49578)
- \[10.x] Allow Vite asset path customization by
[@&#8203;timacdonald](https://github.com/timacdonald) in
[https://github.com/laravel/framework/pull/49437](https://github.com/laravel/framework/pull/49437)
- \[10.x] Type hinting of the second parameter of date- and time-related
`where*()` methods of `Illuminate\Database\Query\Builder` by
[@&#8203;lorenzolosa](https://github.com/lorenzolosa) in
[https://github.com/laravel/framework/pull/49599](https://github.com/laravel/framework/pull/49599)
- \[10.x] Fix Stringable::convertCase() return type by
[@&#8203;vaites](https://github.com/vaites) in
[https://github.com/laravel/framework/pull/49590](https://github.com/laravel/framework/pull/49590)
- Allow \Blade::stringable() to be called on native Iterables by
[@&#8203;tsjason](https://github.com/tsjason) in
[https://github.com/laravel/framework/pull/49591](https://github.com/laravel/framework/pull/49591)
- \[10.x] Refactor time handling using `InteractsWithTime` trait method
by [@&#8203;xurshudyan](https://github.com/xurshudyan) in
[https://github.com/laravel/framework/pull/49601](https://github.com/laravel/framework/pull/49601)
- \[10.x] Add `assertCount` test helper by
[@&#8203;xurshudyan](https://github.com/xurshudyan) in
[https://github.com/laravel/framework/pull/49609](https://github.com/laravel/framework/pull/49609)
- \[10.x] Ability to establish connection without using Config
Repository by [@&#8203;deleugpn](https://github.com/deleugpn) in
[https://github.com/laravel/framework/pull/49527](https://github.com/laravel/framework/pull/49527)
- \[10.x] Add APA style title helper by
[@&#8203;hotmeteor](https://github.com/hotmeteor) in
[https://github.com/laravel/framework/pull/49572](https://github.com/laravel/framework/pull/49572)
- \[10.x] Fix usage of alternatives in error output by
[@&#8203;Mrjavaci](https://github.com/Mrjavaci) in
[https://github.com/laravel/framework/pull/49614](https://github.com/laravel/framework/pull/49614)
- \[10.x] Use locks for queue job popping for PlanetScale's
MySQL-compatible Vitess 19 engine by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49561](https://github.com/laravel/framework/pull/49561)

###
[`v10.39.0`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10390---2023-12-27)

[Compare
Source](https://github.com/laravel/framework/compare/v10.38.2...v10.39.0)

- \[9.x] Support for phpredis 6.0.0 by
[@&#8203;MichalHubatka](https://github.com/MichalHubatka) in
[https://github.com/laravel/framework/pull/48380](https://github.com/laravel/framework/pull/48380)
- \[10.x] Dynamic `maxTries` for queued jobs by
[@&#8203;mechelon](https://github.com/mechelon) in
[https://github.com/laravel/framework/pull/49473](https://github.com/laravel/framework/pull/49473)
- \[10.x] Avoid TypeError when using json validation rule when PHP < 8.3
by [@&#8203;Xint0](https://github.com/Xint0) in
[https://github.com/laravel/framework/pull/49474](https://github.com/laravel/framework/pull/49474)
- \[10.x] Fix use statement compilation in Blade templates by
[@&#8203;MrPunyapal](https://github.com/MrPunyapal) in
[https://github.com/laravel/framework/pull/49479](https://github.com/laravel/framework/pull/49479)
- \[10.x] Allow testing prompts validation by
[@&#8203;cerbero90](https://github.com/cerbero90) in
[https://github.com/laravel/framework/pull/49447](https://github.com/laravel/framework/pull/49447)
- \[10.x] Add 'Roundrobin' Symfony mailer transport driver by
[@&#8203;me-shaon](https://github.com/me-shaon) in
[https://github.com/laravel/framework/pull/49435](https://github.com/laravel/framework/pull/49435)

###
[`v10.38.2`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10382---2023-12-22)

[Compare
Source](https://github.com/laravel/framework/compare/v10.38.1...v10.38.2)

- \[10.x] Add `conflict` for `doctrine/dbal:^4.0` to
`illuminate/database` by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49456](https://github.com/laravel/framework/pull/49456)
- \[10.x] Simplify Arr::dot by
[@&#8203;bastien-phi](https://github.com/bastien-phi) in
[https://github.com/laravel/framework/pull/49461](https://github.com/laravel/framework/pull/49461)
- \[10.x] Illuminate\Filesystem\join_paths(): Argument
[#&#8203;2](https://github.com/laravel/framework/issues/2) must be of
type string, null given by
[@&#8203;tylernathanreed](https://github.com/tylernathanreed) in
[https://github.com/laravel/framework/pull/49467](https://github.com/laravel/framework/pull/49467)
- \[10.x] Allow deprecation logging in tests by
[@&#8203;timacdonald](https://github.com/timacdonald) in
[https://github.com/laravel/framework/pull/49457](https://github.com/laravel/framework/pull/49457)
- \[10.x] Fix missing Validation rules not working with nested array by
[@&#8203;aabadawy](https://github.com/aabadawy) in
[https://github.com/laravel/framework/pull/49449](https://github.com/laravel/framework/pull/49449)

###
[`v10.38.1`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10381---2023-12-20)

[Compare
Source](https://github.com/laravel/framework/compare/v10.38.0...v10.38.1)

- \[10.x] Adds support for parse callbacks from anonymous classes by
[@&#8203;nunomaduro](https://github.com/nunomaduro) in
[https://github.com/laravel/framework/pull/49432](https://github.com/laravel/framework/pull/49432)
- Revert "\[10.x] Drop the primary key if it exists when adding a new
primary key" by
[@&#8203;taylorotwell](https://github.com/taylorotwell) in
[https://github.com/laravel/framework/pull/49448](https://github.com/laravel/framework/pull/49448)
- \[10.x] Fix installing DBAL on a fresh app by
[@&#8203;timacdonald](https://github.com/timacdonald) in
[https://github.com/laravel/framework/pull/49438](https://github.com/laravel/framework/pull/49438)
- \[10.x] Add method to create request by
[@&#8203;dododedodonl](https://github.com/dododedodonl) in
[https://github.com/laravel/framework/pull/49446](https://github.com/laravel/framework/pull/49446)
- \[10.x] Move `Illuminate\Foundation\Application::joinPaths()` to
`Illuminate\Filesystem\join_paths()` by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49433](https://github.com/laravel/framework/pull/49433)

###
[`v10.38.0`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10380---2023-12-19)

[Compare
Source](https://github.com/laravel/framework/compare/v10.37.3...v10.38.0)

- \[10.x] Add routeRoute method to test request by
[@&#8203;fragkp](https://github.com/fragkp) in
[https://github.com/laravel/framework/pull/49366](https://github.com/laravel/framework/pull/49366)
- \[10.x] Update import & typo by
[@&#8203;chu121su12](https://github.com/chu121su12) in
[https://github.com/laravel/framework/pull/49370](https://github.com/laravel/framework/pull/49370)
- \[10.x] Show default `false` values in `db:table` command by
[@&#8203;PerryvanderMeer](https://github.com/PerryvanderMeer) in
[https://github.com/laravel/framework/pull/49379](https://github.com/laravel/framework/pull/49379)
- \[10.x] Fix primary key creation for MySQL with
`sql_require_primary_key` enabled by
[@&#8203;mtawil](https://github.com/mtawil) in
[https://github.com/laravel/framework/pull/49374](https://github.com/laravel/framework/pull/49374)
- \[10.x] Add `charset` and `collation` method to `Blueprint` by
[@&#8203;gcazin](https://github.com/gcazin) in
[https://github.com/laravel/framework/pull/49396](https://github.com/laravel/framework/pull/49396)
- Fixes second run of `about` command on Octane by
[@&#8203;josecl](https://github.com/josecl) in
[https://github.com/laravel/framework/pull/49387](https://github.com/laravel/framework/pull/49387)
- \[10.x] Fix bug in ArrayLock getCurrentOwner by
[@&#8203;Joostb](https://github.com/Joostb) in
[https://github.com/laravel/framework/pull/49393](https://github.com/laravel/framework/pull/49393)
- \[10.x] Dynamo Batch Repository - Match Default Horizon Sort by
[@&#8203;evan-burrell](https://github.com/evan-burrell) in
[https://github.com/laravel/framework/pull/49391](https://github.com/laravel/framework/pull/49391)
- \[10.x] Add Blade `[@session](https://github.com/session)` Directive
by [@&#8203;jrd-lewis](https://github.com/jrd-lewis) in
[https://github.com/laravel/framework/pull/49339](https://github.com/laravel/framework/pull/49339)
- \[10.x] Improve `Arr::dot` performance by
[@&#8203;bastien-phi](https://github.com/bastien-phi) in
[https://github.com/laravel/framework/pull/49386](https://github.com/laravel/framework/pull/49386)
- \[10.x] Fix assertStatus() parameter order by
[@&#8203;marcovo](https://github.com/marcovo) in
[https://github.com/laravel/framework/pull/49404](https://github.com/laravel/framework/pull/49404)
- \[10.x] Only set `defaultCasters` if not previously set by
[@&#8203;inxilpro](https://github.com/inxilpro) in
[https://github.com/laravel/framework/pull/49402](https://github.com/laravel/framework/pull/49402)
- \[10.x] Fixes parameter type in `ManagesFrequencies` by
[@&#8203;Lucas-Schmukas](https://github.com/Lucas-Schmukas) in
[https://github.com/laravel/framework/pull/49399](https://github.com/laravel/framework/pull/49399)
- \[10.x] Add SQLite support for `whereJsonContains` method by
[@&#8203;danieleambrosino](https://github.com/danieleambrosino) in
[https://github.com/laravel/framework/pull/49401](https://github.com/laravel/framework/pull/49401)
- \[10x.] Use native json_validate in Validation by
[@&#8203;gtjamesa](https://github.com/gtjamesa) in
[https://github.com/laravel/framework/pull/49413](https://github.com/laravel/framework/pull/49413)
- \[10.x] Introducing `isEmpty` and `isNotEmpty` to
`ComponentAttributeBag` by
[@&#8203;devajmeireles](https://github.com/devajmeireles) in
[https://github.com/laravel/framework/pull/49408](https://github.com/laravel/framework/pull/49408)
- \[10.x] Drop the primary key if it exists when adding a new primary
key by [@&#8203;KieranFYI](https://github.com/KieranFYI) in
[https://github.com/laravel/framework/pull/49392](https://github.com/laravel/framework/pull/49392)
- \[10.x] Improve schema builder `getColumns()` method by
[@&#8203;hafezdivandari](https://github.com/hafezdivandari) in
[https://github.com/laravel/framework/pull/49416](https://github.com/laravel/framework/pull/49416)
- \[10.x] Add `MailMessage` helpers for plain text email notifications
by [@&#8203;onlime](https://github.com/onlime) in
[https://github.com/laravel/framework/pull/49407](https://github.com/laravel/framework/pull/49407)
- \[10.x] Test Improvements by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49426](https://github.com/laravel/framework/pull/49426)
- \[10.x] Add Conditionable to Pipeline by
[@&#8203;shane-zeng](https://github.com/shane-zeng) in
[https://github.com/laravel/framework/pull/49429](https://github.com/laravel/framework/pull/49429)

###
[`v10.37.3`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10373---2023-12-13)

[Compare
Source](https://github.com/laravel/framework/compare/v10.37.2...v10.37.3)

- Flush middleware callbacks by
[@&#8203;taylorotwell](https://github.com/taylorotwell) in
laravel/framework@bb49a72

###
[`v10.37.2`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10372---2023-12-13)

[Compare
Source](https://github.com/laravel/framework/compare/v10.37.1...v10.37.2)

- Ability to test chained job via closure by
[@&#8203;jasonmccreary](https://github.com/jasonmccreary) in
[https://github.com/laravel/framework/pull/49337](https://github.com/laravel/framework/pull/49337)
- \[10.x] Add `progress` option to `PendingBatch` by
[@&#8203;orkhanahmadov](https://github.com/orkhanahmadov) in
[https://github.com/laravel/framework/pull/49273](https://github.com/laravel/framework/pull/49273)
- \[10.x] Test Improvements by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49338](https://github.com/laravel/framework/pull/49338)
- \[10.x] Avoid using `rescue()` in standalone `illuminate/database`
component. by [@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49355](https://github.com/laravel/framework/pull/49355)
- \[10.x] Exclude extension types on PostgreSQL when retrieving types by
[@&#8203;hafezdivandari](https://github.com/hafezdivandari) in
[https://github.com/laravel/framework/pull/49358](https://github.com/laravel/framework/pull/49358)
- \[10.x] Revert "\[10.x] Disconnecting the database connection after
testing" by [@&#8203;driesvints](https://github.com/driesvints) in
[https://github.com/laravel/framework/pull/49361](https://github.com/laravel/framework/pull/49361)

###
[`v10.37.1`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10371---2023-12-12)

[Compare
Source](https://github.com/laravel/framework/compare/v10.37.0...v10.37.1)

- \[10.x] Disconnecting the database connection after testing by
[@&#8203;KentarouTakeda](https://github.com/KentarouTakeda) in
[https://github.com/laravel/framework/pull/49327](https://github.com/laravel/framework/pull/49327)
- \[10.x] Get user-defined types on PostgreSQL by
[@&#8203;hafezdivandari](https://github.com/hafezdivandari) in
[https://github.com/laravel/framework/pull/49303](https://github.com/laravel/framework/pull/49303)

###
[`v10.37.0`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10370---2023-12-12)

[Compare
Source](https://github.com/laravel/framework/compare/v10.36.0...v10.37.0)

- \[10.x] Add `engine` method to `Blueprint` by
[@&#8203;jbrooksuk](https://github.com/jbrooksuk) in
[https://github.com/laravel/framework/pull/49250](https://github.com/laravel/framework/pull/49250)
- \[10.x] Use translator from validator in `Can` and `Enum` rules by
[@&#8203;fancyweb](https://github.com/fancyweb) in
[https://github.com/laravel/framework/pull/49251](https://github.com/laravel/framework/pull/49251)
- \[10.x] Get indexes of a table by
[@&#8203;hafezdivandari](https://github.com/hafezdivandari) in
[https://github.com/laravel/framework/pull/49204](https://github.com/laravel/framework/pull/49204)
- \[10.x] Filesystem : can lock file on append of content by
[@&#8203;StephaneBour](https://github.com/StephaneBour) in
[https://github.com/laravel/framework/pull/49262](https://github.com/laravel/framework/pull/49262)
- \[10.x] Test Improvements by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49266](https://github.com/laravel/framework/pull/49266)
- \[10.x] Fixes generating facades documentation shouldn't be affected
by `php-psr` extension by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49268](https://github.com/laravel/framework/pull/49268)
- \[10.x] Fixes `AboutCommand::format()` docblock by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49274](https://github.com/laravel/framework/pull/49274)
- \[10.x] `Route::getController()` should return `null` when the
accessing closure based route by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49269](https://github.com/laravel/framework/pull/49269)
- \[10.x] Add "noActionOnUpdate" method in
Illuminate/Database/Schema/ForeignKeyDefinition by
[@&#8203;hrsa](https://github.com/hrsa) in
[https://github.com/laravel/framework/pull/49297](https://github.com/laravel/framework/pull/49297)
- \[10.x] Fixing number helper for floating 0.0 by
[@&#8203;mr-punyapal](https://github.com/mr-punyapal) in
[https://github.com/laravel/framework/pull/49277](https://github.com/laravel/framework/pull/49277)
- \[10.x] Allow checking if lock succesfully restored by
[@&#8203;Joostb](https://github.com/Joostb) in
[https://github.com/laravel/framework/pull/49272](https://github.com/laravel/framework/pull/49272)
- \[10.x] Enable DynamoDB as a backend for Job Batches by
[@&#8203;khepin](https://github.com/khepin) in
[https://github.com/laravel/framework/pull/49169](https://github.com/laravel/framework/pull/49169)
- \[10.x] Removed deprecated and not used argument by
[@&#8203;Muetze42](https://github.com/Muetze42) in
[https://github.com/laravel/framework/pull/49304](https://github.com/laravel/framework/pull/49304)
- \[10.x] Add Conditionable to Batched and Chained jobs by
[@&#8203;bretto36](https://github.com/bretto36) in
[https://github.com/laravel/framework/pull/49310](https://github.com/laravel/framework/pull/49310)
- \[10.x] Include partitioned tables on PostgreSQL when retrieving
tables by [@&#8203;hafezdivandari](https://github.com/hafezdivandari)
in
[https://github.com/laravel/framework/pull/49326](https://github.com/laravel/framework/pull/49326)
- \[10.x] Allow to pass `Arrayable` or `Stringble` in rules `In` and
`NotIn` by
[@&#8203;michaelnabil230](https://github.com/michaelnabil230) in
[https://github.com/laravel/framework/pull/49055](https://github.com/laravel/framework/pull/49055)
- \[10.x] Display error message if json_encode() fails by
[@&#8203;aimeos](https://github.com/aimeos) in
[https://github.com/laravel/framework/pull/48856](https://github.com/laravel/framework/pull/48856)
- \[10.x] Allow error list per field by
[@&#8203;timacdonald](https://github.com/timacdonald) in
[https://github.com/laravel/framework/pull/49309](https://github.com/laravel/framework/pull/49309)
- \[10.x] Get foreign keys of a table by
[@&#8203;hafezdivandari](https://github.com/hafezdivandari) in
[https://github.com/laravel/framework/pull/49264](https://github.com/laravel/framework/pull/49264)
- \[10.x] PHPStan Improvements by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49343](https://github.com/laravel/framework/pull/49343)
- \[10.x] Handle missing translations: more robust handling of callback
return value by [@&#8203;DeanWunder](https://github.com/DeanWunder) in
[https://github.com/laravel/framework/pull/49341](https://github.com/laravel/framework/pull/49341)

###
[`v10.36.0`](https://github.com/laravel/framework/compare/v10.35.0...v10.36.0)

[Compare
Source](https://github.com/laravel/framework/compare/v10.35.0...v10.36.0)

###
[`v10.35.0`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10350---2023-12-05)

[Compare
Source](https://github.com/laravel/framework/compare/v10.34.2...v10.35.0)

- \[10.x] Add `Conditionable` trait to `AssertableJson` by
[@&#8203;khalilst](https://github.com/khalilst) in
[https://github.com/laravel/framework/pull/49172](https://github.com/laravel/framework/pull/49172)
- \[10.x] Add `--with-secret` option to Artisan `down` command. by
[@&#8203;jj15asmr](https://github.com/jj15asmr) in
[https://github.com/laravel/framework/pull/49171](https://github.com/laravel/framework/pull/49171)
- \[10.x] Add support for `Number::summarize` by
[@&#8203;jcsoriano](https://github.com/jcsoriano) in
[https://github.com/laravel/framework/pull/49197](https://github.com/laravel/framework/pull/49197)
- \[10.x] Add Blade [@&#8203;use](https://github.com/use) directive by
[@&#8203;simonhamp](https://github.com/simonhamp) in
[https://github.com/laravel/framework/pull/49179](https://github.com/laravel/framework/pull/49179)
- \[10.x] Fixes retrying failed jobs causes PHP memory exhaustion errors
when dealing with thousands of failed jobs by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49186](https://github.com/laravel/framework/pull/49186)
- \[10.x] Add "substituteImplicitBindingsUsing" method to router by
[@&#8203;calebporzio](https://github.com/calebporzio) in
[https://github.com/laravel/framework/pull/49200](https://github.com/laravel/framework/pull/49200)
- \[10.x] Cookies Having Independent Partitioned State (CHIPS) by
[@&#8203;fabricecw](https://github.com/fabricecw) in
[https://github.com/laravel/framework/pull/48745](https://github.com/laravel/framework/pull/48745)
- \[10.x] Update InteractsWithDictionary.php to use base
InvalidArgumentException by [@&#8203;Grldk](https://github.com/Grldk)
in
[https://github.com/laravel/framework/pull/49209](https://github.com/laravel/framework/pull/49209)
- \[10.x] Fix docblock for wasRecentlyCreated by
[@&#8203;stancl](https://github.com/stancl) in
[https://github.com/laravel/framework/pull/49208](https://github.com/laravel/framework/pull/49208)
- \[10.x] Fix loss of attributes after calling child component by
[@&#8203;rojtjo](https://github.com/rojtjo) in
[https://github.com/laravel/framework/pull/49216](https://github.com/laravel/framework/pull/49216)
- \[10.x] Fix typo in PHPDoc comment by
[@&#8203;caendesilva](https://github.com/caendesilva) in
[https://github.com/laravel/framework/pull/49234](https://github.com/laravel/framework/pull/49234)
- \[10.x] Determine if the given view exists. by
[@&#8203;hafezdivandari](https://github.com/hafezdivandari) in
[https://github.com/laravel/framework/pull/49231](https://github.com/laravel/framework/pull/49231)

###
[`v10.34.2`](https://github.com/laravel/framework/compare/v10.34.1...v10.34.2)

[Compare
Source](https://github.com/laravel/framework/compare/v10.34.1...v10.34.2)

###
[`v10.34.1`](https://github.com/laravel/framework/compare/v10.34.0...v10.34.1)

[Compare
Source](https://github.com/laravel/framework/compare/v10.34.0...v10.34.1)

###
[`v10.34.0`](https://github.com/laravel/framework/blob/HEAD/CHANGELOG.md#v10340---2023-11-28)

[Compare
Source](https://github.com/laravel/framework/compare/v10.33.0...v10.34.0)

- \[10.x] Fix `hex_color` validation rule by
[@&#8203;apih](https://github.com/apih) in
[https://github.com/laravel/framework/pull/49070](https://github.com/laravel/framework/pull/49070)
- \[10.x] Prevent passing null to base64\_decode in Encrypter by
[@&#8203;robtesch](https://github.com/robtesch) in
[https://github.com/laravel/framework/pull/49071](https://github.com/laravel/framework/pull/49071)
- \[10.x] Alias Number class by
[@&#8203;ziadoz](https://github.com/ziadoz) in
[https://github.com/laravel/framework/pull/49073](https://github.com/laravel/framework/pull/49073)
- \[10.x] Added File Validation `extensions` by
[@&#8203;eusonlito](https://github.com/eusonlito) in
[https://github.com/laravel/framework/pull/49082](https://github.com/laravel/framework/pull/49082)
- \[10.x] Add [@&#8203;throws](https://github.com/throws) in
doc-blocks by
[@&#8203;imanghafoori1](https://github.com/imanghafoori1) in
[https://github.com/laravel/framework/pull/49091](https://github.com/laravel/framework/pull/49091)
- \[10.x] Update docblocks for consistency by
[@&#8203;dwightwatson](https://github.com/dwightwatson) in
[https://github.com/laravel/framework/pull/49092](https://github.com/laravel/framework/pull/49092)
- \[10.x] Throw exception when trying to initiate `Collection` using
`WeakMap` by [@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49095](https://github.com/laravel/framework/pull/49095)
- \[10.x] Only stage committed transactions by
[@&#8203;hansnn](https://github.com/hansnn) in
[https://github.com/laravel/framework/pull/49093](https://github.com/laravel/framework/pull/49093)
- Better transaction manager object design by
[@&#8203;taylorotwell](https://github.com/taylorotwell) in
[https://github.com/laravel/framework/pull/49103](https://github.com/laravel/framework/pull/49103)
- \[10.x] use php 8.3 `mb_str_pad()` for `Str::pad*` by
[@&#8203;amacado](https://github.com/amacado) in
[https://github.com/laravel/framework/pull/49108](https://github.com/laravel/framework/pull/49108)
- \[10.x] Add Conditionable to TestResponse by
[@&#8203;nshiro](https://github.com/nshiro) in
[https://github.com/laravel/framework/pull/49112](https://github.com/laravel/framework/pull/49112)
- \[10.x] Allow multiple types in Collection's `ensure` method by
[@&#8203;ash-jc-allen](https://github.com/ash-jc-allen) in
[https://github.com/laravel/framework/pull/49127](https://github.com/laravel/framework/pull/49127)
- \[10.x] Fix middleware "SetCacheHeaders" with download responses by
[@&#8203;clementbirkle](https://github.com/clementbirkle) in
[https://github.com/laravel/framework/pull/49138](https://github.com/laravel/framework/pull/49138)
- \[10.x]\[Cache] Fix handling of `false` values in apc by
[@&#8203;simivar](https://github.com/simivar) in
[https://github.com/laravel/framework/pull/49145](https://github.com/laravel/framework/pull/49145)
- \[10.x] Reset numeric rules after each attribute's validation by
[@&#8203;apih](https://github.com/apih) in
[https://github.com/laravel/framework/pull/49142](https://github.com/laravel/framework/pull/49142)
- \[10.x] Extract dirty getter for `performUpdate` by
[@&#8203;taka-oyama](https://github.com/taka-oyama) in
[https://github.com/laravel/framework/pull/49141](https://github.com/laravel/framework/pull/49141)
- \[10.x] `ensure`: Resolve `$itemType` outside the closure by
[@&#8203;lucasmichot](https://github.com/lucasmichot) in
[https://github.com/laravel/framework/pull/49137](https://github.com/laravel/framework/pull/49137)
- Allow "missing" method to be used on route groups by
[@&#8203;redelschaap](https://github.com/redelschaap) in
[https://github.com/laravel/framework/pull/49144](https://github.com/laravel/framework/pull/49144)
- \[10.x] Get tables and views info by
[@&#8203;hafezdivandari](https://github.com/hafezdivandari) in
[https://github.com/laravel/framework/pull/49020](https://github.com/laravel/framework/pull/49020)
- \[10.x] Fix `MorphTo::associate()` PHPDoc parameter by
[@&#8203;devfrey](https://github.com/devfrey) in
[https://github.com/laravel/framework/pull/49162](https://github.com/laravel/framework/pull/49162)
- \[10.x] Make test error messages more multi-byte readable by
[@&#8203;nshiro](https://github.com/nshiro) in
[https://github.com/laravel/framework/pull/49160](https://github.com/laravel/framework/pull/49160)
- \[10.x] Generate a unique hash for anonymous components by
[@&#8203;billyonecan](https://github.com/billyonecan) in
[https://github.com/laravel/framework/pull/49156](https://github.com/laravel/framework/pull/49156)
- \[10.x] Improves output when using `php artisan about --json` by
[@&#8203;crynobone](https://github.com/crynobone) in
[https://github.com/laravel/framework/pull/49154](https://github.com/laravel/framework/pull/49154)
- \[10.x] Make fake instance inherit from `Vite` when using
`withoutVite()` by
[@&#8203;orkhanahmadov](https://github.com/orkhanahmadov) in
[https://github.com/laravel/framework/pull/49150](https://github.com/laravel/framework/pull/49150)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/RadioRoster/backend).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy45My4xIiwidXBkYXRlZEluVmVyIjoiMzcuMTUzLjIiLCJ0YXJnZXRCcmFuY2giOiJtYWluIn0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@tomgrohl
Copy link

Looks like this PR was based on an article I wrote here: https://blog.devgenius.io/how-to-stream-json-responses-in-laravel-9-and-10-6eccd67b0d65

You can see there has been a copy/paste for this section:

/** @var TestResponse $this */
$this->baseResponse = new JsonResponse(
    getResponseContent($this->baseResponse),
    $this->baseResponse->getStatusCode(),
    $this->baseResponse->headers->all(),
    0,
    true
);

FYI /** @var TestResponse $this */ was only needed because I was declaring a test response macro, so this could have been left out

It would have been nice to have been cited on this.

@ppwalks24
Copy link

I've seen this prior as stated above. Plagiarism springs to mind!

@JosephSilber
Copy link
Contributor

@tomgrohl
Copy link

@JosephSilber thanks.

I think I tried something like that but it didn't work. I'm pretty sure I ended up with an empty array in my response. I'm not at a computer to confirm this.

I think this is because the logic written by Symfony requires a closure to be passed that is a generator.

When you loop via the cursor call, this yields from a generator, then you yield from the outer closure too.

This is how I understood it from reading Symfony's docs before I wrote the article.

@pelmered
Copy link
Contributor Author

pelmered commented Feb 13, 2024

Looks like this PR was based on an article I wrote here: https://blog.devgenius.io/how-to-stream-json-responses-in-laravel-9-and-10-6eccd67b0d65

You can see there has been a copy/paste for this section:

/** @var TestResponse $this */
$this->baseResponse = new JsonResponse(
    getResponseContent($this->baseResponse),
    $this->baseResponse->getStatusCode(),
    $this->baseResponse->headers->all(),
    0,
    true
);

FYI /** @var TestResponse $this */ was only needed because I was declaring a test response macro, so this could have been left out

It would have been nice to have been cited on this.

I did the whole implementation by just looking at the Symfony documentation.
At the end I realised I might need some testing in the PR and I wasn't sure how to do that in PHP. That is probably when I found that article through some Googling. In the end, I ended up not using that code anyway as it was better to just use assertStreamedContent instead.

So why would I cite you?

@cerbero90
Copy link
Contributor

@JosephSilber according to the implementation all sort of objects are supported:

  • iterables will be traversed
  • all other objects will be simply json encoded

so in short, this is possible:

response()->streamJson([
    'users' => User::cursor(),
]);

as the lazy collection will be iterated 👍

side note for @pelmered: thanks for this PR! :) it would also be great to add the method streamJson() to the Illuminate\Contracts\Routing\ResponseFactory interface

@tomgrohl
Copy link

@cerbero90 thanks for confirming.

I was retesting this morning to check if it worked. Makes it nicer and easier to implement if you don't have to write the generator closure.

@pelmered If you didn't use my work then thats fine, no need to cite.

@tomgrohl
Copy link

As a side note I've updated my article to say its now in Laravel from 10.43: https://blog.devgenius.io/how-to-stream-json-responses-in-laravel-9-and-10-6eccd67b0d65

@pelmered
Copy link
Contributor Author

@JosephSilber according to the implementation all sort of objects are supported:

* iterables will be traversed

* all other objects will be simply json encoded

so in short, this is possible:

response()->streamJson([
    'users' => User::cursor(),
]);

as the lazy collection will be iterated 👍

side note for @pelmered: thanks for this PR! :) it would also be great to add the method streamJson() to the Illuminate\Contracts\Routing\ResponseFactory interface

Yes, that sounds like a good addition. I will see if I can add that.

@macropay-solutions
Copy link

macropay-solutions commented Apr 22, 2025

@pelmered
We just finished implementing this StreamedJsonResponse in our cruFd lib suite and we saw it was not streaming at all, but just builds the response in output buffer until it fills the memory if the table is big enough.

In symfony documentation they mention that you should use flush once in a while.

image

We did flush after each 100 rows and also we put a sleep after flushing, but no luck.
The memory issue persisted.

Analog with ob_flush().

We tested this on our demo page/website. Could there be a server setup that prevents streaming or is this an issue from symfony?

Update

We set in php.ini

output_buffering = 1024

and then the response changed to

{
    "has_more_pages": false,
    "sums": {
        "value": null
    },
    "avgs": {
        "value_avg": null
    },
    "mins": {
        "value_min": null,
        "created_at_min": null
    },
    "maxs": {
        "value_max": null,
        "created_at_max": null
    },
    "index_required_on_filtering": [
        "id",
        "parent_id",
        "client_id",
        "created_at",
        "currency",
        "value"
    ],
    "current_page": 1,
    "from": 1,
    "last_page": 1,
    "per_page": 3748918,
    "to": 3748918,
    "total": 3748918,
    "data":

Previously it was valid json but data did not contain any rows, just a "message": "Server error"

Lets continue the discussion here: #55509

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants