0
では見られない、私はGuzzleHttpクライアントクラスSymfony2の
http://docs.guzzlephp.org/en/5.3/quickstart.html
からGuzzleHttpにロードされていると私は、このアクションを呼び出すとき
use GuzzleHttp\Client;
を持っている...
public function googlevolumeAction(Request $request)
{
$data = $request->request->all();
$searchStr = $data['search'];
$client = new Client();
$req = $client->request('GET', 'https://www.googleapis.com/books/v1/volumes?q=intitle:' .$searchStr, []);
$decode = json_decode($req->getBody());
$total = $decode->totalItems;
$search = null;
if ($total != 0) {
$search = $decode->items;
}
return $this->render('BloggerBlogBundle:Page:googlevolume.html.twig',
['items' => $search]);
}
このエラーが発生します...
Attempted to load class "Client" from namespace "GuzzleHttp".
Did you forget a "use" statement for e.g. "Guzzle\Http\Client",
"Guzzle\Service\Client", "Symfony\Component\BrowserKit\Client",
"Symfony\Component\HttpKernel\Client" or
"Symfony\Bundle\FrameworkBundle\Client"?
なぜでしょうか?
おかげ
アプリケーションにどのようにインストールしましたか? – zerkms
私は "guzzlehttp/guzzle"を "require"しています: "^ 3.8"とそれをベンダーフォルダに更新しました – CarlRyds
古いバージョンのguzzleがインストールされている可能性があります。私は "guzzlehttp/guzzle"を持っています: "^ 6.2"ベンダーの下のClientクラスをチェックして名前空間を確認してください。これは以前のバージョンとは異なります。 \ Guzzleを使うことについてのコメントは無視してください...先行するバックスラッシュは必要ありません。そして、はい、グレッグ3.xは非常に古いです。それを使用する必要がある場合は、適切な文書に従ってください。 – Cerad