Laravel websockets
Dear Team i am using laravel version 8.1.7, i could not figure out the bootstrap file where i need to enabled
import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: 'mykey',
wsHost: window.location.hostname,
wsPort: 6001,
forceTLS: false,
disableStats: true,
});
kindly guide
Replies (1)
Hi,
To enable the Laravel Echo with Pusher in your Laravel project, you need to follow these steps:
- Install Pusher and Laravel Echo using NPM:
- Configure the Laravel Echo by adding the following code in your resources/js/bootstrap.js file:
- Make sure to replace <code>mykey</code> with your actual Pusher API key.
Make sure to include the bootstrap.js file in your webpack.mix.js file:
<pre> mix.js('resources/js/bootstrap.js', 'public/js'); You can then use Laravel Echo in your Vue components or JavaScript files as follows: </pre>- You can then use Laravel Echo in your Vue components or JavaScript files as follows:
- Replace 'channel-name' and 'EventName' with your actual channel and event names, respectively.
Thanks