PHP code example of mainul12501 / zego-audio-video-calling
1. Go to this page and download the library: Download mainul12501/zego-audio-video-calling library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mainul12501 / zego-audio-video-calling example snippets
// Request
POST /api/call/initiate
Content-Type: application/json
Authorization: Bearer {token}
{
"receiver_id": 2,
"call_type": "video"
}
// Response
{
"success": true,
"call": {
"id": 123,
"caller_id": 1,
"receiver_id": 2,
"room_id": "room_xyz123_1638475647",
"call_type": "video",
"status": "initiated",
"created_at": "2024-01-15T10:30:00Z"
},
"room_url": "/call/call-page?roomID=room_xyz123_1638475647&type=video&chatWith=2"
}
'routes' => [
'web' => [
'enabled' => true,
'prefix' => 'call', // Change route prefix
'middleware' => ['web', 'auth'], // Add custom middleware
],
'mobile' => [
'enabled' => true,
'prefix' => 'api/mobile/call',
'middleware' => ['api', 'auth:sanctum'],
],
],
'user_model' => App\Models\User::class,
'call_settings' => [
'max_call_duration' => 3600, // Maximum call duration in seconds
'auto_end_missed_calls' => true, // Auto-end missed calls
'missed_call_timeout' => 60, // Missed call timeout in seconds
'enable_call_history' => true, // Enable call history tracking
],
bash
php artisan vendor:publish --provider="ZegoAudioVideoCalling\ZegoAudioVideoCallingServiceProvider"
bash
# Publish configuration
php artisan vendor:publish --tag=zego-calling-config
# Publish migrations
php artisan vendor:publish --tag=zego-calling-migrations
# Publish views (optional, for customization)
php artisan vendor:publish --tag=zego-calling-views
# Publish assets (CSS/JS)
php artisan vendor:publish --tag=zego-calling-assets
bash
php artisan migrate
bash
php artisan vendor:publish --tag=zego-calling-views
bash
npm install --save-dev laravel-echo pusher-js