How to connect two laravel applications?

I have 2 laravel applications (5.2) that use the same database. 2 applications are used by two different types of users. Now I want them to connect to each other, so when a request is sent from the user using the first application to save data to a specific database table, a notification is sent to the second application with this data. How can i do this??

+4
source share
1 answer

In the past, I have done the following:

  • Create a queued job in APP1 with an empty handler.
  • Running jobs in a queue in APP1
  • Create a queued job in APP2 with a populated handler.
  • APP2 (php artisan queue:listen )

APP1. :

# APP1 - trigger

\Queue::push(new \App\Jobs\EventToBeWorkedOnInApp1());

# app1/Jobs/EventToBeWorkedOnInApp1.php - job
class EventToBeWorkedOnInApp1 extends Job implements SelfHandling, ShouldQueue
{
    use SerializesModels;
    public function handle()
    {
        // @handler is in APP2
    }
(...)

APP2   # APP2

    # app1/Jobs/EventToBeWorkedOnInApp1.php - job
    class EventToBeWorkedOnInApp1 extends Job implements SelfHandling, ShouldQueue
    {
        use SerializesModels;
        public function handle()
        {
            // WORK WITH THE JOB
        }
    (...)
0

Source: https://habr.com/ru/post/1671545/


All Articles