You cannot respond with a model as such. You can send string that the other end can parse.
Perhaps explain why it needs to be sent through Http (and to where) and why you need it to send models?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a situation where a large amount of data needs to be fetched from the database and then sent through HTTP, and i am looking for a way to improve the performance of it.
I am considering streaming the data but,
To give an example, i have 2 apps.
App 1
The App 1 will get the data from the database, and it will return a stream response.
Route::get('/stream', function(){
return response()->stream(function() {
Items::query()->chunk(200, function($items){
echo json_encode($items);
});
});
}, 200, [
'Content-Type' => 'application/json',
]);
App 2
$response = $app1->get('/stream');
i want to get the data as models and not string
$response->getContent() it returns false$response->streamedContent() it returns a string with all the dataPlease or to participate in this conversation.