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

4

Version 5.3 of Laravel has some news, such as Broadcasting , for example.

I read the documentation, but I could not quite understand it.

I have seen that it has some relation (if direct or indirect, I do not know) with the Websockets. I also saw that in the routes folder, there is a file named channels.php , where there is a sample 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 about in Laravel?

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

  • What is the relationship between Laravel's 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

    
asked by anonymous 05.09.2017 / 13:47

2 answers

1

The broadcast serves a lot of things, eg you want to trigger a push to all clients 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.

link

    
05.09.2017 / 21:54
0

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

Former link

    
05.09.2017 / 14:15