Skip to content

arifhossen-dev/livewire-chat-app

 
 

Repository files navigation

Livewire Chat App

It's WIP but already usable

Getting Started 🚀

These instructions will guide you through setting up the project on your local machine for development and testing.

Prerequisites

You need to have installed the following software:

  • PHP 8.3
  • Composer 2.0.8
  • Node 20.10.0
  • Redis (optional, for Reverb scaling)

Installing

Follow these steps to set up a development environment:

  1. Clone the repository

    git clone https://github.com/mrpunyapal/livewire-chat-app.git
  2. Install dependencies

    composer install
    npm install
  3. Duplicate the .env.example file and rename it to .env

    cp .env.example .env
  4. Generate the application key

    php artisan key:generate

    Configure environment variables for Reverb (optional but recommended)

    Add the following to your .env file for Reverb configuration:

    BROADCAST_CONNECTION=reverb
    REVERB_APP_ID=your-app-id
    REVERB_APP_KEY=your-app-key  
    REVERB_APP_SECRET=your-app-secret
    REVERB_HOST="localhost"
    REVERB_PORT=8080
    REVERB_SCHEME=http
    VITE_REVERB_APP_KEY="${REVERB_APP_KEY}"
    VITE_REVERB_HOST="${REVERB_HOST}"
    VITE_REVERB_PORT="${REVERB_PORT}"
    VITE_REVERB_SCHEME="${REVERB_SCHEME}"

    Queue Configuration

    You can keep the queue driver as sync for local development, or start a queue worker for better performance:

    # For local development (synchronous processing)
    QUEUE_CONNECTION=sync
    
    # Or use database queue for background processing
    QUEUE_CONNECTION=database
  5. Run migration and seed

    php artisan migrate --seed
  6. Run the application

    You need to run these commands in separate terminal windows:

    # Terminal 1: Start the frontend build process
    npm run dev
    # Terminal 2: Start the Laravel development server
    php artisan serve
    # Terminal 3: Start Reverb WebSocket server for real-time features
    php artisan reverb:start

    Optional: If using database queue driver, start the queue worker in a fourth terminal:

    # Terminal 4: Start queue worker (only if QUEUE_CONNECTION=database)
    php artisan queue:listen

How to Test the Application 🧪

  • Copy .env.testing.example to .env.testing

  • Run the following commands

    php artisan key:generate --env=testing
    npm install && npm run build
    # Lint the code using Pint
    composer lint
    composer test:lint
    
    # Refactor the code using Rector
    composer refactor
    composer test:refactor
    
    # Run PHPStan
    composer test:types
    
    # Run type coverage
    composer test:type-coverage
    
    # Run the test suite
    composer test:unit
    
    # Run all the tests
    composer test

Check composer.json for more details on scripts.

Give Feedback 💬

Give your feedback on @MrPunyapal

Contribute 🤝

Contribute if you have any ideas to improve this project.

About

Livewire Chat App with Laravel Reverb

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 56.2%
  • Blade 41.2%
  • CSS 1.8%
  • JavaScript 0.8%