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

kay899's avatar

Using Lumen for reading a REST API

Hi,

perhaps I am just blind, but I cannot find any example how to use Lumen for reading out data from a REST API.

There are tons of examples how to make an API with Lumen, but not the other way around?!

Can someone give me an example how to read in data from an API and use this content or just show me a tutorial which I have not found?

Thanks and best wishes kay

0 likes
7 replies
willvincent's avatar

Yup.. Guzzle is straightforward and easy to use.. read the docs, it's all there -- aside from maybe what the api endpoints are you want to hit on the API you're trying to consume. But hopefully it's at least somewhat documented. :)

http://guzzle3.readthedocs.org/

kay899's avatar

Thanks for your answers.

I try to use Guzzle like this, but I get a 500 error:

http://laravel.io/bin/PXaL8

When I ask for that URL via Browser or a RESTClient I'll get my JSON structure back.

Any ideas?

Thanks!

willvincent's avatar

your api.local server is the one with the issue, not the client you pasted code for. The api server is throwing the 500 error.

Check error logs for that and see what's up.

kay899's avatar

@willvincent thanks for the fast answer.

error log says: lumen.ERROR: exception 'PDOException' with message 'SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)'

But I don't use homestead. I use Windows XAMPP and SQLITE as database, which is defined in .ENV

willvincent's avatar

it would seem your .env file isn't being evaluated properly then..

Please or to participate in this conversation.