DEV Community

Shobi
Shobi

Posted on

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.Original Stack overflow question

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

  1. A Laravel server - Which will serve HTML pages by querying an API (Preferably no DB interaction)
  2. 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?

Top comments (2)

Collapse
 
achoarnold profile image
Arnold Acho

I think many things will depend on the specifics of the App.

TO understand you better, You want to build say 2 microservices where 1 serves as an API where the other service just consumes data from the API

Now you can implement a use the Implement the JSON Web Token authentication as another User above mentioned.

So the Lumen App will be the server which generates the token while the laravel app will use the token generated by the Lumen app to perform it's authentication.

Collapse
 
johnmccuk profile image
John McCracken

You could try integrating JSON Web Token (JWT) authentication and making it stateless.

jwt-auth repository