dqtdz08206 2016-09-09 08:14
浏览 77
已采纳

Laravel在生产服务器上抛出ReflectionException(nginx)

I've just deployed my app on Digitalocean. My upload image and the send email features which worked perfectly fine on my local server doesn't work on the production server. After debugging, I realized the problem is with this two.

Mail::send('emails.contact', $data, ....
Image::make($image);

$image is the image gotten from the post request.

My folder has a write permission for the web group. so I'm sure it isn't a permission problem. Besides, I have commented the save line out and I am still getting the error. Please help. Thanks. Here is my controller code

$images = $request->file('images');
$imageEmpty = array_filter($images);

if(!(empty($imageEmpty))){
    //$images = $request->file('images');
    $filePath = 'img/posts/'.$post->id.'/';
    File::makeDirectory(public_path($filePath));
    foreach ($images as $image){
        $filename = $image->getClientOriginalName();
        //Image::make($image)->resize(500,500)->save(public_path($filePath.$filename));
        $img = new Img;
        $img->name = $filename;
        $post->images()->save($img);

        Image::make($image); //->save(public_path($filePath.$filename));
    }

Here is my mailing controller

    $data = array(
      'email' => $request->email,
      'bodyMessage' => $request->message,
      'subject' => $request->subject
    );
    Mail::send('emails.contact', $data, function($message) use ($data){
        $message->from($data['email']);
        $message->to('badmustaofeeq@gmail.com');
        $message->subject($data['subject']);
    });
    Session::flash('success',' Email was sent successfully!');
    return redirect()->route('contact.get');
}

Here is my stacktrace

[2016-09-07 22:10:26] production.ERROR: ReflectionException: Class App\Http\Controller$ Stack trace: #0 /var/www/laravel/bootstrap/cache/compiled.php(8572): ReflectionMethod->__construct($ #1 /var/www/laravel/bootstrap/cache/compiled.php(8281): Illuminate\Routing\Route->sign$ #2 /var/www/laravel/bootstrap/cache/compiled.php(8275): Illuminate\Routing\Router->sub$ #3 /var/www/laravel/bootstrap/cache/compiled.php(8266): Illuminate\Routing\Router->sub$ #4 /var/www/laravel/bootstrap/cache/compiled.php(8212): Illuminate\Routing\Router->fin$ #5 /var/www/laravel/bootstrap/cache/compiled.php(8207): Illuminate\Routing\Router->dis$ #6 /var/www/laravel/bootstrap/cache/compiled.php(2419): Illuminate\Routing\Router->dis$ #7 [internal function]: Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\$ #8 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(52): $ #9 /var/www/laravel/bootstrap/cache/compiled.php(3286): Illuminate\Routing\Pipeline->I$ #10 [internal function]: Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode$ #11 /var/www/laravel/bootstrap/cache/compiled.php(9963): call_user_func_array(Array, A$ #12 [internal function]: Illuminate\Pipeline\Pipeline->Illuminate\Pipeline{closure}(O$ #13 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32):$ #14 [internal function]: Illuminate\Routing\Pipeline->Illuminate\Routing{closure}(Obj$ #15 /var/www/laravel/bootstrap/cache/compiled.php(9948): call_user_func(Object(Closure$ #16 /var/www/laravel/bootstrap/cache/compiled.php(2366): Illuminate\Pipeline\Pipeline-$ #17 /var/www/laravel/bootstrap/cache/compiled.php(2350): Illuminate\Foundation\Http\Ke$ #18 /var/www/laravel/public/index.php(53): Illuminate\Foundation\Http\Kernel->handle(O$ #19 {main

  • 写回答

1条回答 默认 最新

  • dongzhiyong8577 2016-09-09 19:09
    关注

    This reply helped me solved it. https://www.digitalocean.com/community/questions/error-reflectionexception-class-app-http-controller-stack-trace

    Here is the answer..

    " Based on the fact that this code worked properly on your build system but not on your droplet lets work under the assumption that this error is caused by a difference in the environment and not the code itself.

    Without having this narrowed down to just one of those two functions there are a few possibilities.

    Mail PHP's mail functionality requires you have a local MTA on your system. Doing apt-get install postfix or apt-get install sendmail would meet those requirements and allow PHP applications to send emails. Image - image manipulation in PHP usually requires additional libraries such as php7.0-gd or php7.0-imagick which do the heavy lifting. You can install these with apt-get install php7.0-imagick php7.0-gd."

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

报告相同问题?

悬赏问题

  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 如何提取csv文件中需要的列,将其整合为一篇完整文档,并进行jieba分词(语言-python)
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题
  • ¥15 求大家看看Nonce如何配置