这是我的路线文件:
Route::get('/','guzzle@guzzle');
这是我的控制器类:
use App\Http\Requests;
use GuzzleHttp\Client;
class guzzle extends Controller
{
public function guzzle(){
$client = new GuzzleHttp\Client();
$request = $client->head('http://www.amazon.com');
$response = $request->send();
echo $response->getContentLength();
它在浏览器中给了我以下错误消息:
guzzle.php第17行中的FatalErrorException:找不到
类'App \ Http \ Controllers \ GuzzleHttp \ Client'
我不知道如何解决此问题。谁能帮我?
您还可以使用以下方法摆脱名称空间前缀:
$client = new \GuzzleHttp\Client();
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句