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.1 or later
- Laravel version 10 or later
- Livewire version 3.2.3 or later
Installing
1. Install the package via Composer
Before installing, ensure that authentication is already set up in your application. For more information, check out Laravel Breeze
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. Run the installation command
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
Building Tailwind CSS for Production
To purge the CSS classes used by the package, add these lines to the purge
array in tailwind.config.js
:
'./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:
-
High Priority (
messages
): For real-time broadcasting of messages to users in a conversation. -
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.