3

I spend a week teaching what are Websockets and how to use them. What is the logic and architecture of all this. I want to create a simple Laravel application with live-chat or live-notifications.

So, at the moment I found tens of ways and nothing concrete from A to Z. Using Redis, NodeJS, socket.io and Laravel. Using Ratchet library, using 3-rd party services like Pusher.com.

Someone suggested me that Laravel , Laravel echo and socket.io and nothing more.

I really get in stuck. From my understanding, anyway for achieving it all, we need 2 Servers, one back-end(Laravel), one for WebSockets, and client-side for emit and listen for events.

What is the easiest technologies for achieve it w/o 3-rd party priced services, and why?

From one tutorial, I found an idea of creating a server at NodeJS and socket.io for server&client. And create a easy live-chat. But have no Idea how to connect it all now with Laravel, and if it's the right way.

Can please someone explain all that logic and give a good advice and explanation of all that process?

P.S. I read broadcasting Laravel documentation and tons of tutorials and youtube-lessons. I can't find a way of binding all that architecture together. Thanks.

priMo-ex3m
  • 1,072
  • 2
  • 15
  • 29

2 Answers2

1

First of all I wold like to tell you that if you want to use laravel Echo then currently it's only providing one way communication from server to client via sockets. whereas to send data from client to server these are using API's calls.

Now If you want to use simple sockets then I will recommend use ratchet package to use two way communication using ratchet library, here is the reference link: https://medium.com/@errohitdhiman/real-time-one-to-one-and-group-chat-with-php-laravel-ratchet-websocket-library-javascript-and-c64ba20621ed

0

There are plenty of tutorials.

First understand why do you need to use a third party server for websockets (you don't have to but you want to).

Then:

A step by step guide to socket.io and Laravel

Using Pusher and Laravel

Nicolas Bernard
  • 155
  • 2
  • 12
  • I already read all that stuff and know how to use Pusher. But `step-by-step` tuttorial sucks, cause it's just some lines of code and not explained. And also used `nginx` and configured for unknown conditions. Also It's pretty old (Laravel `5.1`). – priMo-ex3m Feb 27 '18 at 08:25
  • 2
    Please add all relevant information to your answer instead of linking to external sources – Nico Haase Nov 19 '19 at 10:03