1

Is it possible to have one Laravel application listen for events triggered in another?

I've built a REST API to complement an existing web app. It uses the same database but I've built it as a separate application and there are certain events which clear some cached results. At the moment the events are not being shared between the two applications so I'm getting the cached results in spite of having updated the database. Is there a way for one app to pick up on events fired by the other? I haven't found anything about this in the docs.

Matthew Daly
  • 9,212
  • 2
  • 42
  • 83

1 Answers1

2

Redis is completely agnostic about what application is listening to it. You can set your broadcast driver to redis and invoke your events in one application while listening on the other as long as they both use the same Redis instance. The other can then listen for those events. However, of note is that the way that Laravel handles the listeners is to bind to a specific class. So you would still have to make sure the class existed so you may define a listener for it.

Ohgodwhy
  • 49,779
  • 11
  • 80
  • 110
  • I had a feeling that might be the case - unfortunately the legacy app my API integrates with is using Pusher, not Redis, and there's no scope for changing that. I'm thinking I'm probably going to have to resort to creating a webhook that the API triggers. Regardless, thanks very much for your answer. – Matthew Daly Jan 23 '17 at 11:35
  • How to achieve this with Pusher – Gaetan Sobze Apr 14 '18 at 00:00