A simple chat application built with Laravel and Vue.js that uses Laravel Reverb for WebSockets.
- ✅ One-to-one chat (Direct Messages)
- ✅ Group chat
- ✅ Real‑time messaging via Laravel Reverb
- ✅ Authentication with Laravel Sanctum
- ✅ Modern UI with Vue.js and Tailwind CSS
- ✅ Full API surface for chat operations
- PHP 8.2+
- Composer
- Node.js and npm
- SQLite (default) or another supported database
- Clone the repository:
git clone https://github.com/ATNoosh/lara_chat
cd lara_chat- Install PHP dependencies:
composer install- Install Node.js dependencies:
npm install- Create your environment file:
cp .env.example .env- Generate the application key:
php artisan key:generate- Run database migrations and seeders:
php artisan migrate:fresh --seed- Build frontend assets (for production):
npm run buildOpen two terminals (or use separate tabs):
- Start Laravel HTTP server:
php artisan serve --host=127.0.0.1 --port=8000- Start Reverb (WebSocket) server:
php artisan reverb:start --host=127.0.0.1 --port=8080- Optional: start Vite dev server (for hot reload during development):
npm run devNotes for Windows PowerShell:
- Use
;between commands instead of&&. - If a port is already in use, change the
--portvalue and update the matching.envvalues accordingly.
- Navigate to
http://127.0.0.1:8000 - Register a new account or log in
- Click "Start New Chat" to create a conversation
- Pick an existing user to start a direct chat, or create a group chat
POST /api/auth/login— Log inPOST /api/auth/register— Register
GET /api/chat_groups— List chat groupsPOST /api/chat_groups— Create a new chat group (DM or group)GET /api/chat_groups/{uuid}— Show a chat groupPUT /api/chat_groups/{uuid}— Update a chat groupDELETE /api/chat_groups/{uuid}— Delete a chat group
GET /api/chat_groups/{groupUuid}/messages— List messages in a groupPOST /api/chat_groups/{groupUuid}/messages— Send a new messagePOST /api/chat_groups/{groupUuid}/messages/read— Mark all as read (for member)POST /api/chat_groups/{groupUuid}/messages/{message}/read— Mark one message as readGET /api/chat_messages/{id}— Show a messagePUT /api/chat_messages/{id}— Update a messageDELETE /api/chat_messages/{id}— Delete a message
GET /api/users— List available users (excluding current user)
app/
├── Events/
│ ├── MessageSent.php
│ ├── MessagesRead.php
│ └── UserTyping.php
├── Http/
│ ├── Controllers/
│ │ ├── Api/AuthenticateController.php
│ │ ├── ChatGroupController.php
│ │ └── ChatMessageController.php
│ └── Requests/
├── Models/
│ ├── ChatGroup.php
│ ├── ChatGroupMember.php
│ ├── ChatMessage.php
│ └── User.php
└── Repositories/
resources/js/
├── Pages/
│ ├── Chat/ChatApp.vue
│ └── Auth/
│ ├── Login.vue
│ └── Register.vue
├── app.js
├── bootstrap.js
└── echo.js
To use WebSockets with Reverb, ensure these environment variables are set in your .env (adjust host/ports if needed):
BROADCAST_CONNECTION=reverb
REVERB_APP_ID=local
REVERB_APP_KEY=local
REVERB_APP_SECRET=local
REVERB_HOST=127.0.0.1
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}To validate real‑time behavior:
- Create two different users
- Log in with each user in separate browsers or private windows
- Start a direct message or a group chat between them
- Messages, read receipts, and typing indicators should update in real time
- For production, review and harden security settings
- Use queues (Redis or database) for broadcasting if needed
- Enable SSL/TLS for WebSockets in production
- Review CORS settings for your API and WebSockets
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
This project is released under the MIT License.