Communication with Socket.IO
To make our backend app communicate with the frontend via Socket.IO, we need the Laravel Echo Server. To do this, we first need to install the Laravel Echo Server npm
package globally. We install it by running npm install –g laravel-echo-server
. Then we will run this package to create the configuration file for setting up the communication.
To do this, we create a new folder and then run laravel-echo-server init
to run the command-line wizard to create the Laravel Echo Server configuration file in the folder. At this point, we can just answer all the questions that are asked with the default settings. This is because we are going to edit the configuration file that it creates once this wizard is done.
Once the wizard is done, we should see the laraval-echo-server.json
file in the folder. Now we open it and replace whatever is in there with the following code:
{ "authHost": "http://localhost:8000", "authEndpoint...