rsodhia's avatar

Creating a global variable (current user)

I'm creating middleware to validate a login cookie, and I'm not sure how I should store the current user object. I suspect this is more about OOP design than Laravel/Lumen directly, but should I be creating a global variable that I can reference as needed, or should I create an object of some sort (a singleton) that stores the variable?

0 likes
1 reply
MaxMatteo's avatar

you could bind it into the service conainer with $app->singleton of course!

Please or to participate in this conversation.