The New Way to Build with AI! Introducing ReUI — the developer platform for agentic UI with shadcn/ui
Browse ReUI Pro

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


Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(

Replies (1)

Hi,

To enable the Laravel Echo with Pusher in your Laravel project, you need to follow these steps:

  1. Install Pusher and Laravel Echo using NPM:
<pre> npm install --save pusher-js laravel-echo </pre>
  1. Configure the Laravel Echo by adding the following code in your resources/js/bootstrap.js file:
<pre> 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, }); </pre>
  1. 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>
  1. You can then use Laravel Echo in your Vue components or JavaScript files as follows:
<pre> Echo.channel('channel-name') .listen('EventName', (data) => { console.log(data); }); </pre>
  1. Replace 'channel-name' and 'EventName' with your actual channel and event names, respectively.

Thanks

Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
Text formatting options
Submit
Click any option to insert into your comment. Select text first to wrap it.
  • **text** to make things bold
  • *text* to emphasize
  • ### Heading to make headings
  • [link text](url) for links
  • ![alt text](image-url) to paste in an image
  • - item to make a list
  • 1. item to make an ordered list
  • > quote to quote somebody
  • `code` for single line of code
  • ```js ... ``` for JS code block
  • ```html ... ``` for HTML code block
  • ```scss ... ``` for SCSS code block
  • ```php ... ``` for PHP code block
  • --- for a horizontal rule
  • happy  :)
  • shocked  :|
  • sad  :(
buy metronic keenthemes mega bundle

ReUI

Open-source React components, blocks and templates built on shadcn/ui and Tailwind CSS by Keenthemes.