Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Obydul's avatar

Laravel 9.16.0, PHP 8.1 Truncated Response (Array/JSON)

I've updated the PHP version to 8.1.6. Then it doesn't return full response. Here's an example:

Code:

$data = [
    'success' => true,
    'message' => 'Updated'
];
return response()->json($data);

Response:


{"success":true,"message":"Updated

In the response, it includes a 'new line' first, then it shows incomplete response (missing curly bracket at the end).

I'm using: PHP 8.1.6 and Laravel 9.16.0.

Please help me to resolve the issue. Thank you.

0 likes
6 replies
Rykono's avatar

Also having the same problem, after i just ran a composer update. Also on php 8.1 and laravel 9. Also same exact problem where the last character of the json is being truncated. Doesn't matter if my controller is returning an array or using response()->json().

Assuming that im using the wrong version or something of some core laravel dependecy. Symfony or something?

jlrdw's avatar

@Rykono did you try deleting the vendor folder and running:

composer clearcache
composer selfupdate
composer updare
or
composer install

Also clear all other cache.

Edit

Also try deleting the folders in bootstrap\cache Not .gitignore however.

Rykono's avatar

I had tried everything but the composer selfupdate and the delete folders in bootstrap/cache. Just tried those and and still same results.

Had also done the typical laravel commands

php artisan clear
php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
Obydul's avatar
Obydul
OP
Best Answer
Level 3

I've downgraded "symfony/http-foundation" version to "6.0.9" and it has resolved the issue.

"require": {
    ---
    "symfony/http-foundation": "6.0.*"
},

I also opened an issue in the Laravel GitHub repo. You can take a look: https://github.com/laravel/framework/issues/42681

** Note: Symfony has resolved the issue in version v6.1.1.

Thanks.

Please or to participate in this conversation.