What is the purpose and how to use Broadcasting in Laravel?

Asked

Viewed 1,543 times

4

The version 5.3 of Laravel has some news, as the Broadcasting, for example.

I read the documentation, but I could not understand very well on the subject.

I saw that it has some relation (whether direct or indirect, I do not know) with the Websockets. I also saw that, in the folder routes, there is a file called channels.php, where there is an example code:

Broadcast::channel('App.User.{id}', function ($user, $id) {
    return (int) $user->id === (int) $id;
});

I wanted to know more deeply:

  • What is this Broadcasting in Laravel?

  • In what situations can I use it, for example?

  • What is the relationship between Laravel Broadcasting and Websockets?

The question is intended to have the content in the Portuguese language, due to not finding anything on the Internet in our language

  • By coincidence, I’m working on it today =) If I have a few minutes left, I’ll try to answer something.

  • 1

    It’ll be sensational @LINQ :)

2 answers

1

Broadcast serves many things, example you want to trigger a push for all customers at the same time within the application.

Example: A hospital panel needs to update which beds are available or occupied, Broadcast can update all screens according to the update made.

All other answers are in the documentation.

https://laravel.com/docs/5.5/broadcasting

0

The purpose is to work with Real-time events ex: has 2 open pages one that lists users and another that adds, When adding a new, the page that lists automatically receives the new item.

Ex https://www.youtube.com/watch?v=kNAZNQnig3E

Browser other questions tagged

You are not signed in. Login or sign up in order to post.