找不到laravel类'GuzzleHttp \ Client'

时间:2019-04-08 16:32:59

标签: laravel

<?php
namespace App\Validators;
use GuzzleHttp\Client;
class ReCaptcha
{
    public function validate($attribute, $value, $parameters, $validator)
    {
        $client = new Client;
        $response = $client->post('https://www.google.com/recaptcha/api/siteverify',
            [
                'form_params' =>
                    [
                        'secret' => env('GOOGLE_RECAPTCHA_SECRET'),
                        'response' => $value
                    ]
            ]
        );
        $body = json_decode((string)$response->getBody());
        return $body->success;
    }
}

此代码在服务器上显示错误但在本地运行良好

Class 'GuzzleHttp\Client' not found

这个错误..它是如何在localhost而不是在服务器上工作的

1 个答案:

答案 0 :(得分:1)

首先检查安装并在composer.json文件中存在此库  如果不安装,请使用此命令

php composer.phar require guzzle/guzzle:~3.9

然后

composer dump-autoload