【问题标题】:ReflectionException in Container.php line 719: Class bindings does not existContainer.php 第 719 行中的 ReflectionException:类绑定不存在
【发布时间】:2019-05-06 16:25:55
【问题描述】:

最近我正在为一个项目使用 laravel 5.4(我之前使用过 laravel 5.2)。我的 api.php

中有简单的路线
Route::get('/test', function () {
return "test";
});

当我尝试从 postman 使用 url /api/test 访问此 url 时,我收到以下错误 -

ReflectionException in Container.php line 719:
Class bindings does not exist

我在 laravel 5.2 中使用 api 时没有遇到这种错误。现在我被困在这里。希望有人有解决方案,谢谢。

【问题讨论】:

  • 您没有向我们展示您的所有代码。阅读Route Model binding,因为它可能会引发异常。
  • 它是一个全新的 laravel 5.4 项目,并且在我所写的 api.php 中有一个路由,当我尝试从邮递员访问时,我得到了错误
  • 得到了解决方案,不知何故我在我的 routeMiddleware 'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class 中遗漏了这一行,

标签: php laravel-5.2 laravel-5.3


【解决方案1】:

晚了,但在我的情况下,关注 RouteServiceProvider.php 中的函数 mapWebRoutes 是我找到解决方案的地方。我需要的是“网络”选项。

protected function mapWebRoutes(Router $router)
{
    $router->group([
        'namespace' => $this->namespace, 'middleware' => 'web',
    ], function ($router) {
        require app_path('Http/routes.php');
    });
}

【讨论】:

    猜你喜欢
    • 2016-04-12
    • 2017-05-07
    • 1970-01-01
    • 2016-12-27
    • 1970-01-01
    • 1970-01-01
    • 2016-05-16
    • 2016-04-30
    • 1970-01-01
    相关资源
    最近更新 更多