如何解决Laravel 5.4中的“ BadMethodCallException方法Illuminate \ Routing \ Route :: getParameter不存在”异常?

时间:2019-07-04 21:06:36

标签: laravel-5.4

下午好,我从5.3更新了Laravel 5.4项目,并收到以下错误消息

  

BadMethodCallException方法照亮\ Routing \ Route :: getParameter   不存在。

     

应用程序框架(2)所有框架(27)26 BadMethodCallException   …/供应商/laravel/framework/src/Illuminate/Support/Traits/Macroable.php102   25照亮\路由\路由__call   …/ app / Http / Controllers / BaseControllerTrait.php103 24   App \ Http \ Controllers \ Core \ BaseController __construct [内部] 0 23   ReflectionClass newInstanceArgs   …/供应商/laravel/framework/src/Illuminate/Container/Container.php823   22照亮\容器\容器构建   …/供应商/laravel/framework/src/Illuminate/Container/Container.php667   21照亮\容器\容器解析   …/ vendor / laravel / framework / src / Illuminate / Container / Container.php615   20照亮\容器\容器制造   …/ vendor / laravel / framework / src / Illuminate / Foundation / Application.php767   19照亮\基础\应用程序制作   …/ vendor / laravel / framework / src / Illuminate / Routing / Route.php233 18   照亮\路由\路由getController   …/ vendor / laravel / framework / src / Illuminate / Routing / Route.php833 17   照亮\路由\路由控制器中间件   …/ vendor / laravel / framework / src / Illuminate / Routing / Route.php794 16   照亮\路由\路由收集中间件   …/ vendor / laravel / framework / src / Illuminate / Routing / Router.php693 15   照亮\路由\路由器收集RouteMiddleware   …/ vendor / laravel / framework / src / Illuminate / Routing / Router.php673 14   照亮\路由\路由器运行RouteWithinStack   …/ vendor / laravel / framework / src / Illuminate / Routing / Router.php657 13   照亮\路由\路由器运行   …/ vendor / laravel / framework / src / Illuminate / Routing / Router.php623 12   照亮\路由\路由器dispatchToRoute   …/ vendor / laravel / framework / src / Illuminate / Routing / Router.php612 11   照亮\路由\路由器调度   …/ vendor / laravel / framework / src / Illuminate / Foundation / Http / Kernel.php176   10 Illuminate \ Foundation \ Http \ Kernel   Illuminate \ Foundation \ Http {关闭}   …/供应商/laravel/framework/src/Illuminate/Routing/Pipeline.php30 9   照亮\路由\管道照亮\路由{关闭}   …/ vendor / barryvdh / laravel-debugbar / src / Middleware / InjectDebugbar.php65   8 Barryvdh \ Debugbar \ Middleware \ InjectDebugbar句柄   …/供应商/laravel/framework/src/Illuminate/Pipeline/Pipeline.php163 7   照明\管道\管道照明\管道\管道{关闭}   …/供应商/laravel/framework/src/Illuminate/Routing/Pipeline.php53 6   照亮\路由\管道照亮\路由{关闭}   …/ vendor / laravel / framework / src / Illuminate / Foundation / Http / Middleware / CheckForMaintenanceMode.php62   5 Illuminate \ Foundation \ Http \ Middleware \ CheckForMaintenanceMode句柄   …/供应商/laravel/framework/src/Illuminate/Pipeline/Pipeline.php163 4   照明\管道\管道照明\管道\管道{关闭}   …/供应商/laravel/framework/src/Illuminate/Routing/Pipeline.php53 3   照亮\路由\管道照亮\路由{关闭}   …/供应商/laravel/framework/src/Illuminate/Pipeline/Pipeline.php104 2   然后照亮\ Pipeline \ Pipeline   …/ vendor / laravel / framework / src / Illuminate / Foundation / Http / Kernel.php151   1 Illuminate \ Foundation \ Http \ Kernel sendRequestThroughRouter   …/ vendor / laravel / framework / src / Illuminate / Foundation / Http / Kernel.php116   0 Illuminate \ Foundation \ Http \ Kernel句柄…/ public / index.php53

See a screenshot here

您能告诉我如何解决吗?

3 个答案:

答案 0 :(得分:2)

Illuminate\Routing\Route::getParameter()公共方法已在Laravel 5.4中删除,请改用parameter()方法。阅读更多here

答案 1 :(得分:0)

我认为您使用的是$request->route()->getParameter('...');,在Laravel 5.4中已将其删除

  • Laravel版本:5.4.2
  • PHP版本:N / A
  • 数据库驱动程序和版本:N / A

说明:

Illuminate \ Routing \ Route :: getParameter()公共方法已删除。请改用parameter()方法。

阅读此merged拉取请求

答案 2 :(得分:0)

我通过修改文件夹中的BaseControllerTrait.php文件解决了该问题 / app / http / controllers,删除获取并仅保留参数行

$ site = \ Route :: current()-> Parameter('site');

        if($site)
        {
            $site = \Route::current()->Parameter('site');