jackFlick's avatar

Laravel App with Lumen to call APIs

I have a Laravel Application that is currently using API. We are making a microservices work that would be able to make Lumen create all the APIs but still have Laravel as our main app with Sanctum Auth since Lumen doesn't have Sanctum Auth. And we also want to use the Laravel functionalities at the same time.

Hope may inquiry is clear and hope someone can enlighten me if Laravel + Lumen is possible and where to start.

Thank you in advance!

0 likes
2 replies
Zigi84's avatar
Zigi84
Best Answer
Level 2

If I understood correctly you have a Laravel app which will use different microservices and you want to choose Lumen for microservices?

Is there really a need to separate API and main Laravel app? Microservices are great if you are a really large company, however in my experience with small teams, they are a real pain.

If it's for performance reasons, keep in mind that once you add packages like Eloquent to Lumen, it's performance bonus disappears.

You would still need authentication to figure out, which would lose you a lot of benefits of Sanctum, as you would need a separate auth system for api calls elsewhere.

I would rather restructure the main laravel app like this

/project/App -> regular laravel
/project/Microservice1
		Controllers
		Middlewares
		Requests
		etc.

/project/Microservice2
		etc..

Or any other structure that may suite you. Just add directories to autoloader in compose.json, and laravels DI should work

Please or to participate in this conversation.