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

octal's avatar
Level 1

THE LARAVEL WAY of http get requests to external API

Hello, I need to call an external API doing GET request. I need to set a special key in the header and do the get request and then handle the result.

Actually I'm creating my options array and I'm calling the simple Php file_get_contents(..) to do it.

What's THE LARAVEL way of doing that?

0 likes
6 replies
octal's avatar
Level 1

@MANELGAVALDA - So I'm not wrong, Laravel doesn't provide any library for that. It's really strange, because in the test framework almost all resquest kind are available.

manelgavalda's avatar

@OCTAL - I think something like guzzle it's not available by default, because not in every application you need to call external APIs, and it's so easy to install it, in case you need it.

For exemple axios is already shipped with laravel as a npm dependency (and already configured to work) because you need axios in order to make api calls to your own server.

So unless you want to use javascript (axios) to make the calls, you will need to install something like guzzle.

Cobs's avatar

@octal Testing requests aren't "real" requests sent by an http client. Laravel automaticaly build a SymfonyRequest and send it to HttpKernel of your application.

octal's avatar
Level 1

Thank you. I'm using Guzzle v6 and it's working very well. I have had to setup Wampserver curl extension to use the correct cacert.pem from mozilla website because I was calling an https url and I was gotting the famous error

cURL error 60: SSL certificate: unable to get local issuer certificate

Now it's working :)

Please or to participate in this conversation.