OryxTraining's avatar

How do I tie Laravel and Lumen together?

I have asked this question in SO, But no responses after 20 Hours, if any of you guys can help it by either answering here, or give an upvote in SO so that it gets more attension. https://stackoverflow.com/questions/53043684/how-do-i-tie-laravel-and-lumen-together

I am building an application from scratch which has 2 main parts

A Laravel server - Which will serve HTML pages by querying an API (Preferably no DB interaction) A Lumen Server - Which will be the API being queried (DB interaction goes here) Now I need to log in a user.

I can send username and password from laravel server to the lumen API and get a token back (I think it's the way, correct me if I am wrong).

  • After that what should I do to make the user logged in IN the Laravel server?
  • Keep the token in session with some key?
  • How do I make this work with the Auth::user() functionality in the Laravel Server?
  • Or what are some good approaches to this problem?
0 likes
1 reply
Borisu's avatar

Generally you can communicate with other services (in your case your Lumen server) via a Http Client. For example you can use GuzzleHttp to make a get, post, delete request to your api.

Then you can just move the DB and logic to the Lumen server and ask for authentication via GuzzleHttp. On the other side you'll store the session if the API responds with true for example. It's fairly complex and unless you have a very good reason to do so, just stick to the basics :)

Please or to participate in this conversation.