
Laralord WebSocket
Multi-tenant WebSocket solution with Pusher-like API
Laralord WebSocket is an open-source Laravel project providing a multi-tenant WebSocket solution with a Pusher-like API. Built on Laravel Reverb, it offers real-time communication and includes a CRUD API for application management. You can deploy it standalone—no need to install Reverb in your app. This project is part of the Laralord Project ecosystem.
Features
- Multi-Tenancy: Isolate WebSocket connections and data for multiple tenants.
- Pusher-Compatible API: Seamlessly integrate with Pusher clients for real-time messaging.
- Laravel Reverb: Leverage Laravel’s native WebSocket server for performance and simplicity.
- Application Management: CRUD API to create, read, update, and delete applications.
- Open-Source: Free to use and contribute under the MIT license.
Requirements
- PHP: 8.2 or higher
- Laravel: 11.x
- Composer: Required for dependency management
- Database: PostgreSQL, Redis, or similar
Installation
- Clone the Repository:Copy
git clone https://github.com/laralord-project/websocket.git cd websocket
- Create .env Files:Copy
cp .env.example .env # the env file below need to configure laralord server cp .env.server.example .env.server
- Start Docker Containers:Copy
$ docker compose up -d websocket
After the microservice is up and running, it exposes two ports (default IP is 10.5.0.1):
- Port 8080: For WebSocket connections
- Port 8000: For applications CRUD API
Application Management API
Base URL
http://localhost:8000/api
Authentication
All endpoints require Bearer token authentication:
Authorization: Bearer your_api_token_here
Routes
Method | Endpoint | Controller Action | Description |
---|---|---|---|
GET | /applications | WebsocketAppController@index | List all applications |
POST | /applications | WebsocketAppController@store | Create a new application |
GET | /applications/{;application} | WebsocketAppController@show | Retrieve a specific application |
PUT/PATCH | /applications/{application} | WebsocketAppController@update | Update a specific application |
DELETE | /applications/{application} | WebsocketAppController@destroy | Delete a specific application |
Endpoints
1. List All Applications
GET /applications
Example Request:
curl -X GET http://localhost:8000/api/applications \
-H "Authorization: Bearer your_api_token_here"
Example Response:
{
"data": [
{
"id": "237467559627198718",
"name": "test-app",
"app_key": "w7YCZe2lYJulvSX1rWeyukBCcnlkCxlb",
"app_secret": "7acxDi3qtGSRdPtJCp01uk8sqE6DXmiQ",
"ping_interval": 60,
"allowed_origins": ["*"],
"max_message_size": 10000,
"options": null,
"created_at": "2025-04-16T06:51:18.000000Z",
"updated_at": "2025-04-16T06:51:18.000000Z"
}
],
"meta": {
"current_page": 1,
"total": 1,
"per_page": 15
},
"status": "success"
}
2. Create Application
POST /applications
Parameters:
Name | Type | Required | Description |
---|---|---|---|
name | string | Yes | Application name |
Example Request:
curl -X POST http://localhost:8000/api/applications \
-H "Authorization: Bearer your_api_token_here" \
-H "Content-Type: application/json" \
-d '{"name": "test-app"}'
Example Response:
{
"data": {
"id": "237467559627198718",
"name": "test-app",
"app_key": "w7YCZe2lYJulvSX1rWeyukBCcnlkCxlb",
"app_secret": "7acxDi3qtGSRdPtJCp01uk8sqE6DXmiQ",
"created_at": "2025-04-16T06:51:18.000000Z",
"updated_at": "2025-04-16T06:51:18.000000Z"
},
"status": "success"
}
3. Get Application Details
GET /applications/{id}
Path Parameters:
Name | Type | Description |
---|---|---|
id | string | Application ID to retrieve |
Example Request:
curl -X GET http://localhost:8000/api/applications/237467559627198718 \
-H "Authorization: Bearer your_api_token_here" \
-H "Accept: application/json"
Example Response:
{
"data": {
"id": "237467559627198718",
"name": "test-app",
"app_key": "w7YCZe2lYJulvSX1rWeyukBCcnlkCxlb",
"app_secret": "7acxDi3qtGSRdPtJCp01uk8sqE6DXmiQ",
"created_at": "2025-04-16T06:51:18.000000Z",
"updated_at": "2025-04-16T06:51:18.000000Z"
},
"status": "success"
}
4. Delete Application
DELETE /applications/{id}
Path Parameters:
Name | Type | Description |
---|---|---|
id | string | Application ID to delete |
Example Request:
curl -X GET http://localhost:8000/api/applications/237467559627198718 \
-H "Authorization: Bearer your_api_token_here" \
-H "Accept: application/json"
Example Response:
{
"data": {
"id": "237467559627198718",
"name": "test-app",
"app_key": "w7YCZe2lYJulvSX1rWeyukBCcnlkCxlb",
"app_secret": "7acxDi3qtGSRdPtJCp01uk8sqE6DXmiQ",
"created_at": "2025-04-16T06:51:18.000000Z",
"updated_at": "2025-04-16T06:51:18.000000Z"
},
"status": "success"
}
Usages
1. Install the Required JavaScript Client
npm install laravel-echo pusher-js
GitHub Repository: Visit the Laralord Websocket GitHub repository for source code, issues, and contributions.
Licensing: Laralord Websocket is licensed under the MIT License. See the LICENSE file for details.