Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gdesoto's avatar

Laravel Echo listening to sub channels with wildcard

I currently have a channel set up for tasks which broadcasts an event when it has been updated:

Echo.channel("system.tasks.${this.task_id}")
    .listen('System.TaskUpdated', event => {
        // Do Stuff
    });
    

There's scenarios where I would like to listen to broadcasts where any task is updated. Is there something similar to:

Echo.channel("system.tasks.*")

The only thing I could think of is have the event broadcast to both "system.tasks.{task_id}" and "system.tasks". However, that then doubles the number of messages sent. I'm no where near my Pusher daily limit, just was curious if there was a better / more efficient way to accomplish what I'm trying to do.

0 likes
1 reply
jjudge's avatar

This is pretty old, but I don't think you can subscribe to channels by wildcard.

However, each event can broadcast to multiple channels, so an event could broadcast to both "system.tasks.{id}" and "system.tasks". Return them as an array from broadcastOn().

Use broadcastWith() to include the information you need the receiver to get in the event, so that is still available in the wider "system.tasks" channel.

Please or to participate in this conversation.