In my Laravel app and as a scheduled task, I want to make an Http request in my custom class but I get
Class 'Illuminate\Support\Facades\Http' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class 'Illuminate\\Support\\Facades\\Http' not found
Here is my custom class
<?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));
}
}
in Laravel documentation, it says :
To make requests, you may use the get, post, put, patch, and delete methods. First, let's examine how to make a basic GET request:
use Illuminate\Support\Facades\Http;
$response = Http::get('http://test.com');
Http
is not a Facade that I'm aware of. What documentation are you referencing on its usage? – Tim LewisGuzzleHttp
; cool. I'm familiar with that. Did you run the composer command?composer require guzzlehttp/guzzle
– Tim Lewiscomposer dump-autoload
, just in case that didn't get updated. Following that, try again, and if that doesn't work, then dophp artisan tinker
, followed by$http = new Illuminate\Support\Facades\Http();
; it should output something. Let me know when you've tried that. – Tim Lewis