<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Masum Rahman Hasan</title>
    <description>The latest articles on DEV Community by Masum Rahman Hasan (@masumrahmanhasan).</description>
    <link>https://dev.to/masumrahmanhasan</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F430118%2F4c8fd329-d5ac-4053-b227-62e1cbc6275f.jpeg</url>
      <title>DEV Community: Masum Rahman Hasan</title>
      <link>https://dev.to/masumrahmanhasan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/masumrahmanhasan"/>
    <language>en</language>
    <item>
      <title>laravel reverb installation process and setup with common mistakes</title>
      <dc:creator>Masum Rahman Hasan</dc:creator>
      <pubDate>Mon, 10 Jun 2024 09:16:19 +0000</pubDate>
      <link>https://dev.to/masumrahmanhasan/laravel-reverb-installation-process-and-setup-with-common-mistakes-4elb</link>
      <guid>https://dev.to/masumrahmanhasan/laravel-reverb-installation-process-and-setup-with-common-mistakes-4elb</guid>
      <description>&lt;p&gt;Installing and setting up Reverb in a Laravel project involves several steps. Reverb is a package that allows for a quick implementation of real-time broadcasting features in a Laravel application. Here's a step-by-step guide:&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Laravel Installation: Ensure you have a Laravel project set up.&lt;/li&gt;
&lt;li&gt;Composer: Make sure Composer is installed on your system.&lt;/li&gt;
&lt;li&gt;Node.js and npm: These are required for front-end dependencies.&lt;/li&gt;
&lt;li&gt;Step 1: Install Laravel Echo and Pusher&lt;/li&gt;
&lt;li&gt;Install Laravel Echo: Laravel Echo is a JavaScript library that makes it easy to work with WebSockets in Laravel.&lt;/li&gt;
&lt;li&gt;Install Pusher: Pusher is a WebSocket service that is commonly used with Laravel Echo.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step 1: Install Laravel Reverb. You may install Reverb using the install:broadcasting Artisan command:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;php artisan install:broadcasting
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Behind the scenes, the &lt;code&gt;install:broadcasting&lt;/code&gt; Artisan command will run the &lt;code&gt;reverb:install&lt;/code&gt; command, which will install Reverb with a sensible set of default configuration options. If you would like to make any configuration changes, you may do so by updating Reverb's environment variables or by updating the config/reverb.php configuration file.&lt;/p&gt;

&lt;p&gt;You may define these credentials using the following environment variables:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;REVERB_APP_ID=my-app-id
REVERB_APP_KEY=my-app-key
REVERB_APP_SECRET=my-app-secret
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you are using auth but no api then you dont have to use any other extra configuration but there are several configurations for some api authentication system. Lets configure for those &lt;/p&gt;

&lt;h2&gt;
  
  
  Sanctum or Passport
&lt;/h2&gt;

&lt;p&gt;if you are using sanctum api authentication then you have to set some things while using the ECHO&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Echo from 'laravel-echo';

import Pusher from 'pusher-js';
window.Pusher = Pusher;

window.Echo = new Echo({
    broadcaster: 'reverb',
    key: import.meta.env.VITE_REVERB_APP_KEY,
    wsHost: import.meta.env.VITE_REVERB_HOST,
    wsPort: import.meta.env.VITE_REVERB_PORT,
    wssPort: import.meta.env.VITE_REVERB_PORT,
    forceTLS: (import.meta.env.VITE_REVERB_SCHEME ?? 'https') === 'https',
    enabledTransports: ['ws', 'wss'],
auth: {
        headers: {
            Authorization: useCookie('accessToken').value,  // If using token-based auth
        },
    },

});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;as you can see i have added auth param in the echo. if you dont use this for private channel it will give you error. So you need to pass the authentication token. cause by default the route middleware is &lt;code&gt;auth&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;and also you need to add a special thing on the &lt;code&gt;channel.php&lt;/code&gt; file without that your private channel will not work for token based authentication&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Broadcast::routes(['middleware' =&amp;gt; ['auth:sanctum']]);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if you use other token based authentication then add that middleware here in &lt;code&gt;channel.php&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This will solve the 403 forbidden issue for private channel&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>reverb</category>
      <category>broadcasting</category>
      <category>realtime</category>
    </item>
    <item>
      <title>Is there Any way to use laravel Default auth with vue to send response?</title>
      <dc:creator>Masum Rahman Hasan</dc:creator>
      <pubDate>Thu, 13 Aug 2020 06:32:44 +0000</pubDate>
      <link>https://dev.to/masumrahmanhasan/is-there-any-way-to-use-laravel-default-auth-with-vue-to-send-response-3i5h</link>
      <guid>https://dev.to/masumrahmanhasan/is-there-any-way-to-use-laravel-default-auth-with-vue-to-send-response-3i5h</guid>
      <description>

</description>
      <category>laravel</category>
      <category>vue</category>
      <category>php</category>
    </item>
  </channel>
</rss>
