Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Daniel1836's avatar

How can I connect to an external API without Guzzle on Laravel shared host site?

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

0 likes
1 reply

Please or to participate in this conversation.