@yanik2103 @lukegalea16
This is very easy to implement btw, I've been doing this for years already since version 5.4
What you need to do is set your session driver in config/session.php to database, and create the migrations with these commands for all your projects.
Memcached or Redis driver for the session will do too.
for reference here https://laravel.com/docs/8.x/session#database (might vary on depending what version of Laravel you're running this)
php artisan session:table
php artisan migrate
Next, let them all use THE SAME Database, and all your sessions should be sync.
After that, set up your Authentication with Sanctum for mobile applications, and simple, token-based APIs, OR if you want a full OAuth2 server then you can use Passport, both should suffice what you need.
for Passport make sure all 3 applications are using the same oauth-public.key and oauth-private.key found in storage folder. just generate the keys in one app, then copy and paste the keys on all other apps.
OPTIONAL PART, this requires you to have experience in handling servers
These next steps will make all your 3 applications interact and feel like one single application, this lets them talk to each other even on different domains, BUT this is complicated to set up, only do this if you have experience setting up real-time applications and handling servers.
- Set up your
Broadcasting Driver to Redis or Pusher (Pusher is easier but expensive, I don't' use Pusher)
for reference here https://laravel.com/docs/8.x/broadcasting
- Set up
Socket.io for both your backend and frontend (We have Laravel Echo for this in the Frontend)
for Laravel Echo reference here https://laravel.com/docs/8.x/broadcasting#installing-laravel-echo
Next step is for Redis Driver (This is what I do)
- Set up a
NodeJS Server for your Backend Real-time Server (you can use Laravel Echo Server for this)
for Laravel Echo Server reference here https://github.com/tlaverdure/laravel-echo-server
- Point all of your 3 applications
Echo's Auth Path to One Single Laravel Echo Server/Domain, you might see something on your laravel-echo-server.json file like this
{
"authHost": "http://app1.test", // choose 1 app for all of your apps where they would authenticate.
"authEndpoint": "/broadcasting/auth",
... other configs
}
Once all of this is running, all of them should be able to Pub/Sub Messages using Notification, meaning you can let them all talk to each other using Broadcasting, so whatever the user is doing on App1 can be read by App2 and App3 using Events.
Like if user1 would do something on App1, App1 can push a message to App2/App3 displaying a Notification/Flash Message or whatever you want in Real-Time and Vice Versa.
This is all pure Laravel way.