DEV Community

Shobi
Shobi

Posted on

2 2

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?

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

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

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay