Laravel 7.x 中未找到“Illuminate\Support\Facades\Http”类

Art*_*tin 7 httprequest laravel

在我的 Laravel 应用程序中,作为计划任务,我想在我的自定义类中发出 Http 请求,但我得到

Class 'Illuminate\Support\Facades\Http' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class 'Illuminate\\Support\\Facades\\Http' not found
Run Code Online (Sandbox Code Playgroud)

这是我的自定义课程

<?php

namespace App\MyModels\GetData;
use Illuminate\Support\Facades\Http;
use Illuminate\Support\Facades\Log;

class Test
{
    public function __invoke()
    {
        Log::info("Cron executed : ");
        $response = Http::get("https://google.com");
        Log::info(print_r($response, true));
    }
}
Run Code Online (Sandbox Code Playgroud)

在 Laravel 文档中,它说:

要发出请求,您可以使用 get、post、put、patch 和 delete 方法。首先,我们来看看如何发出基本的 GET 请求:

使用 Illuminate\Support\Facades\Http;

$response = Http::get(' http://test.com ');

Mik*_*Sli 3

对我来说,这个问题与以下事实有关(虽然我认为该项目是 Laravel 的版本 7),但我似乎使用的是 Laravel 的 6.x 版本。更新到最新版本为我解决了这个问题。链接到解决我的问题的 GitHub 问题

虽然问题是关于版本 7 的,但我仍然觉得这可能对某些人有帮助