Laravel Class #39;AppHttpControllersGuzzleHttpClient#39; not found(未找到 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"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:未找到 Laravel 类“AppHttpControllersGuzzleHttpClient"
基础教程推荐
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何替换eregi() 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
