首页 文章

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

提问于
浏览
1

我刚刚在Digitalocean上部署了我的应用程序 . 我的上传图像和发送电子邮件功能在我的本地服务器上完美运行在 生产环境 服务器上不起作用 . 经过调试,我意识到问题出在这两个问题上 .

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

$ image是从帖子请求中获取的图像 .

我的文件夹具有Web组的写入权限 . 所以我确定这不是一个许可问题 . 此外,我已经注释了保存线,我仍然收到错误 . 请帮忙 . 谢谢 . 这是我的控制器代码

$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));
    }

这是我的邮件控制器

$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');
}

这是我的堆栈跟踪

[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):照亮\路由\路由器 - >子$#/ / / / / / / / / / / / / / / / / / / / / / / /bootstrap/cache/compiled.php(8212):Illuminate \ Routing \ Router-> fin $#/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / #6 /var/www/laravel/bootstrap/cache/compiled.php(2419):Illuminate \ Routing \ Router-> dis $#7 [内部函数]: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 [内部乐趣ction]:Illuminate \ Foundation \ Http \ Middleware \ CheckForMaintenanceMode $#11 /var/www/laravel/bootstrap/cache/compiled.php(9963):call_user_func_array(数组,A $#12 [内部功能]:照亮\管道\ Pipeline-> Illuminate \ Pipeline (O $#13 /var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Pipeline.php(32):$#14 [内部功能]:照亮\ Routing \ Pipeline-> Illuminate \ Routing (Obj $#/ / var / www / ravel / bootstrap / cache / compiled.php(948):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 回答

  • 0

    这个回复帮我解决了 . https://www.digitalocean.com/community/questions/error-reflectionexception-class-app-http-controller-stack-trace

    这是答案..

    “基于这样的事实,即此代码在您的构建系统上正常工作但不在您的Droplet上工作,假设此错误是由环境差异而不是代码本身引起的 .

    如果没有将这些缩小到这两个函数中的一个,那么就有一些可能性 .

    邮件PHP的邮件功能要求您的系统上有本地MTA . 执行 apt-get install postfixapt-get install sendmail 将满足这些要求并允许PHP应用程序发送电子邮件 . 图像 - PHP中的图像处理通常需要额外的库,例如 php7.0-gdphp7.0-imagick 来完成繁重的工作 . 您可以使用 apt-get install php7.0-imagick php7.0-gd 安装它们 . “

相关问题