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

finlamit's avatar

Multiple microservices with lumen, and tying them together

Hi. I am learning about microservers, splitting an application back-end onto multiple servers and then having a single frontend server.

What I am confused about is how I would tie them all together.

For instance, if auth.mydomain.com manages all of the authentication (with its own db of users which contains a api_token column), and articles.mydomain.com manages all of the user posts (with its own db which contains a user_id columns), how would I ensure that the endpoint articles.mydomain.com/delete authentication and user_id is correct?

It's the communication between the multiple services that confuses me? Any help would be appreciated.

Thanks

M

0 likes
1 reply
robsykes's avatar

You could create UUID that is a sole identifier of the user. The authentication service will be responsible for creating this. Once a user has passed through the authentication service, it will has the unique UUID, that can be passed to other services, in your case, the article service.

The frontend could keep that UUID in a session so it remains, or you could request an authentication every page reload, or you can use JWT.

In an ideal world, each service doesn't really know about the others. However, data is doesn't work like that. Data needs to know about other data sometimes. In such a case, you need common ground, passing a user id or token will allow you to identify the individual making articles.

It's also completely fine for your articles service to make requests against the Authenticate service, for example, if you need to get the user that created the article based on the Id. Make a request to the Authenticate service for it, get the details.

You could go even further, and break up Authenticate service into Auth and User. Auth is literally just for authenticating details and user is for polling/creating users.

Another advantage of doing that way is testing. Your tests are simpler and more focused when you only need to worry about creating/deleting a users/article/etc, rather than also authenticating it.

  • Another point to make - You could later consider Docker Files and Kubernetes to start to string those together. This is something I believe Netflix do. There is good video on YouTube where they talk about it, but I can't seem to find it. Sorry.

Please or to participate in this conversation.