Level 13
@daniel1836 By using what Guzzle is built on top of...CURL or file_get_contents()
https://www.php.net/manual/en/book.curl.php
https://www.php.net/manual/en/function.file-get-contents.php
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I am unable to install guzzle because of a memory issue.
Is there another way to connect to an external API without using Guzzle. Using only code in my controller?
How would I rewrite my code in my controller?
$before = Carbon::now()->subMonths(2)->timestamp;
$after = Carbon::now()->addMonths(2)->timestamp;
$popularGamesUnformatted = Cache::remember('popular-games', 7, function () use ($before, $after) {
$client = new \GuzzleHttp\Client(['base_uri' => 'https://api.igdb.com/v4/games' ]);
$response = $client->request('POST', 'multiquery', [
'headers' => [
'Client-ID'=> 't2qfl3qldbe6vt6sp90gqw2mxk0m20',
'Authorization' => 'Bearer 5xknzmaxkw3ph1f5ivixzfab8ms13q',
],
'body' => '
query games "Playstation" {
fields name, platforms.abbreviation,cover.url,slug,rating, first_release_date;
limit 100;
};
'
]);
$body = $response->getBody();
$game = json_decode($body, true);
return $game;
I would need to implement the api url, authorization and my query.
Thanks
Please or to participate in this conversation.