dsxrq28228 2017-08-02 18: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-02 19: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
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部