未找到 Laravel 类“AppHttpControllersGuzzleHttpClient"

Laravel Class #39;AppHttpControllersGuzzleHttpClient#39; not found(未找到 Laravel 类“AppHttpControllersGuzzleHttpClient)
本文介绍了未找到 Laravel 类“AppHttpControllersGuzzleHttpClient"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经安装了客户端并使用 composer dump autoload 进行了更新,但我仍然遇到同样的错误.通过 composer 安装后在项目目录下需要 guzzlehttp/guzzle:~6.0.

I've installed the client and I did an update using composer dump autoload but I still end up with the same error. After installing via composer require guzzlehttp/guzzle:~6.0 in the projects directory.

 $client = new GuzzleHttpClient(); 

为什么它不起作用,为什么它甚至引用了错误的目录?

Why isn' it working and why is it even referencing the wrong directory?

推荐答案

你会想要熟悉 PHP 命名空间.

You're going to want to get acquainted with PHP namespaces.

Laravel 中的大多数文件都是命名空间的.对命名空间内的函数的调用始于该命名空间内,但有两个例外:

Most files in Laravel are namespaced. Calls to functions within a namespace start within that namespace, with two exceptions:

如果你用 开始类名,这告诉 PHP 从根级命名空间开始:

If you start the class name with a , that tells PHP to start at the root-level namespace:

$client = new GuzzleHttpClient(); 

或者,你可以说:

use GuzzleHttpClient;

在文件的顶部(你会在 Laravel 的默认文件中看到很多 文件)然后执行

at the top of the file (you'll see a lot of these already throughout Laravel's default files) and then do

$client = new Client();

这篇关于未找到 Laravel 类“AppHttpControllersGuzzleHttpClient"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)