framework: #5.7 BUG# Laravel Expcetion repeat response show

  • Laravel Version: 5.7
  • PHP Version: 7.2

Description:

result is invalid json, repeat show

Steps To Reproduce:

1、composer create-project --prefer-dist laravel/laravel blog 2、cd blog && php artisan serve 3、edit app\Http\Kernel.php file,write in api configure

'api' => [
    ...,
    'json.response', // notice, this middleware is not exists,because these can to reproduce this error
]

4、edit route\api.php, add content

Route::get('/test', function () {
    return 'reproduce error';
});

5、used postman add headers Accept: application/json and get http://localhost:8000/api/test 6、result show is invalid json,this result repeat response show

{
    "message": "Class json.response does not exist",
    "exception": "ReflectionException",
    "file": "/Users/yyj/Docker/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/Container.php",
    "line": 767,
    "trace": [
        {
            "file": "/Users/yyj/Docker/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/Container.php",
            "line": 767,
            "function": "__construct",
            "class": "ReflectionClass",
            "type": "->"
        },
        {
            "file": "/Users/yyj/Docker/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/Container.php",
            "line": 646,
            "function": "build",
            "class": "Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/Users/yyj/Docker/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/Container.php",
            "line": 601,
            "function": "resolve",
            "class": "Illuminate\\Container\\Container",
            "type": "->"
        },
        // more something ....
    ]
}{
    "message": "Class json.response does not exist",
    "exception": "ReflectionException",
    "file": "/Users/yyj/Docker/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/Container.php",
    "line": 767,
    "trace": [
        {
            "file": "/Users/yyj/Docker/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/Container.php",
            "line": 767,
            "function": "__construct",
            "class": "ReflectionClass",
            "type": "->"
        },
        {
            "file": "/Users/yyj/Docker/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/Container.php",
            "line": 646,
            "function": "build",
            "class": "Illuminate\\Container\\Container",
            "type": "->"
        },
        {
            "file": "/Users/yyj/Docker/wwwroot/blog/vendor/laravel/framework/src/Illuminate/Container/Container.php",
            "line": 601,
            "function": "resolve",
            "class": "Illuminate\\Container\\Container",
            "type": "->"
        },
        // more something ....
    ]
}

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (6 by maintainers)

Commits related to this issue

Most upvoted comments

I want to know how to solve this problem

If you create a json.response middleware - that would solve it?