dsxrq28228 2017-08-03 02:51
浏览 405
已采纳

Laravel“调用未定义的方法”,仅在生产中发生

I have 2 controller functions which call a static function of a class located right under app folder.

Controllers\UserResController.php

public function show($id, Request $request)
{
   return \App\User::show($id, $request);
}

Conrtollers\Other\UserResController.php

public function show($id, Request $request)
{
   // other codes

   return \App\User::show($id, $request);
}

app\User.php

public static function show($id, Request $request){
   //codes
}

What surprised me is that these code run OK in development and staging environment but not in production.

It throws exception 'Symfony\Component\Debug\Exception\FatalErrorException' with message 'Call to undefined method App\User::show()'

What causes it? Thanks.

  • 写回答

1条回答 默认 最新

  • dsfg3241 2017-08-03 03:00
    关注

    Chances are the production environment is using an older cached or compiled version. When that happens, I always try:

    composer update
    

    Or

    composer dump-autoload
    

    Or

    php artisan clear-compiled
    

    Or

    php artisan cache:clear
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?