Use session, cache or global variables from Laravel console

Viewed 709

I'm processing transactions for many users, from the console/command. For each user/transaction processed, I need the user_id value accessible in a package I've created.

What would be the best way to share the user_id value to the package? Session variable? Cache helper? A global variable?

Thanks

1 Answers

you can use cache or config.

for config, create a global.php file in the config directory and set your variables by Config::set('global.user_id' , $user->id) and for get that use Config::get('global.user_id')

for more information about config files read this useful link

also you can use redis database

Related