Installation

Wirechat is a simple yet robust chat package built with the TALL Stack, making it easy to integrate into your Laravel app with just a few commands.


#Prerequisites

Before you begin, ensure the following are installed:

  • PHP version 8.2 or later
  • Laravel version 10 or later
  • Livewire version 3.2.3 or later
  • Tailwindcss 3.x|4.x

#Installing

#1. Require the package via Composer

Before installing, ensure that authentication is already set up in your application. You may use any Livewire starter kit or explore Laravel Breeze for a simple authentication setup.

composer require namu/wirechat

⚠️ Beta Notice: Wirechat is currently in beta. While it may not yet be production-ready, we encourage you to explore and test it out. If you encounter any issues, your feedback will be invaluable in helping us refine and improve the package for a stable release.

#2. Install Wirechat

Run this command to install and publish the necessary files:

php artisan wirechat:install

The following actions will be executed:

  • Publish configuration file
  • Publish migration files
  • Create a storage symlink

#3. Run Migrations:

Apply the necessary database migrations with:

php artisan migrate

#Optimizing Tailwind CSS for Production

To ensure Tailwind purges CSS classes from the package, add the following lines to your /resources/css/app.css file:

/* resources/css/app.css */

@source '../../vendor/namu/wirechat/resources/views/**/*.blade.php';
@source '../../vendor/namu/wirechat/src/Livewire/**/*.php';

Note: This package requires the @tailwindcss/forms plugin. Make sure it is installed and included in your Tailwind config.

Using Tailwind CSS v3?

If you're using Tailwind CSS v3, update the content array in your tailwind.config.js file to include these paths:

content: [
  './vendor/namu/wirechat/resources/views/**/*.blade.php',
  './vendor/namu/wirechat/src/Livewire/**/*.php'
]

#WebSockets and Queue Setup

Wirechat uses WebSockets to broadcast messages in real-time to conversations and their participants.

Step 1: Enable Broadcasting

In newer Laravel installations, broadcasting is disabled by default. To enable it, run:

php artisan install:broadcasting

Note: This command will prompt you to install Laravel Reverb and necessary front-end packages such as Echo. Accept if you don’t yet have a WebSocket server set up.

Then, start your Reverb server:

php artisan reverb:start

For more details, refer to the Laravel Broadcasting Documentation, including information on integrating Laravel Echo for real-time updates.

Step 2: Start Your Queue Worker

After configuring broadcasting, start a queue worker to handle message broadcasting and other queued tasks:

php artisan queue:work --queue=messages,default
Queue Prioritization

Wirechat uses two queues for efficient delivery:

  1. High Priority (messages): For real-time broadcasting of messages to users in a conversation.
  2. Default Priority (default): For notifications like updating chat lists or showing unread message counts.

You can customize these queue names in the Wirechat Configuration.

Step 3: Step Development Server

To start your development server, run:

composer run dev

If you're not running the latest Laravel version, you can run: php artisan serve && npm run dev seperately

For more details, see Laravel's Tailwind and Composer Dev Command Documentation.


#Publishing Translations

If you need to customize the language files, you can publish them using the following command:

php artisan vendor:publish --tag=wirechat-translations

#Publishing Views

To modify Wirechat's Blade views, publish them with this command:

php artisan vendor:publish --tag=wirechat-views