PHPackages                             mainul12501/zego-audio-video-calling - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. mainul12501/zego-audio-video-calling

ActiveLibrary[API Development](/categories/api)

mainul12501/zego-audio-video-calling
====================================

A complete Laravel package for ZegoCloud audio and video calling with mobile app support

v1.0.0(5mo ago)00MITPHPPHP ^8.1|^8.2|^8.3|^8.4

Since Dec 2Pushed 5mo agoCompare

[ Source](https://github.com/Mainul12501/zegocloud-audio-video-call)[ Packagist](https://packagist.org/packages/mainul12501/zego-audio-video-calling)[ RSS](/packages/mainul12501-zego-audio-video-calling/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (7)Versions (2)Used By (0)

ZegoCloud Audio &amp; Video Calling Package for Laravel
=======================================================

[](#zegocloud-audio--video-calling-package-for-laravel)

[![Latest Version](https://camo.githubusercontent.com/6edcc906010a77e367e67dd1837a0e17015be60c9cb5fea48c6172c36d44eec7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61696e756c31323530312f7a65676f2d617564696f2d766964656f2d63616c6c696e672e737667)](https://packagist.org/packages/mainul12501/zego-audio-video-calling)[![Total Downloads](https://camo.githubusercontent.com/cea13bfd9ddc357dd21d1b12a095fce3ff493468a2da9986f2d4a6c905d805d3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61696e756c31323530312f7a65676f2d617564696f2d766964656f2d63616c6c696e672e737667)](https://packagist.org/packages/mainul12501/zego-audio-video-calling)[![License](https://camo.githubusercontent.com/72e7347f8a3aa9cea2fd2ac9f030004afba439e6642e4881dec414d832abdc37/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d61696e756c31323530312f7a65676f2d617564696f2d766964656f2d63616c6c696e672e737667)](https://packagist.org/packages/mainul12501/zego-audio-video-calling)

A complete, production-ready Laravel package for implementing ZegoCloud audio and video calling with mobile app support. Just install, configure credentials, and you're ready to go!

Features
--------

[](#features)

✅ **Zero Configuration Setup** - Just add your ZegoCloud credentials to `.env`✅ **Audio &amp; Video Calling** - Full support for both audio and video calls ✅ **Web &amp; Mobile Support** - Works seamlessly across web browsers and mobile apps ✅ **Real-time Communication** - WebSocket broadcasting for call state synchronization ✅ **Push Notifications** - FCM (Android) and APNs (iOS) support for incoming calls ✅ **Call History** - Track and manage call records ✅ **Laravel 10-12+ Compatible** - Supports Laravel 10, 11, 12 and future versions ✅ **Auto-Discovery** - Service provider auto-registration ✅ **Customizable UI** - Beautiful, responsive call interface out of the box ✅ **Mobile API** - RESTful API endpoints for mobile app integration

Table of Contents
-----------------

[](#table-of-contents)

- [Requirements](#requirements)
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage](#usage)
    - [Web Integration](#web-integration)
    - [API Integration](#api-integration)
- [Mobile App Integration](#mobile-app-integration)
- [Customization](#customization)
- [Broadcasting Setup](#broadcasting-setup)
- [Testing](#testing)
- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [License](#license)

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Laravel 10.0 or higher
- ZegoCloud account ([Get one here](https://console.zegocloud.com))
- Laravel Sanctum (for API authentication)
- Laravel Echo &amp; Pusher (for real-time broadcasting)

Installation
------------

[](#installation)

### Step 1: Install via Composer

[](#step-1-install-via-composer)

```
composer require mainul12501/zego-audio-video-calling
```

### Step 2: Publish Package Assets

[](#step-2-publish-package-assets)

```
php artisan vendor:publish --provider="ZegoAudioVideoCalling\ZegoAudioVideoCallingServiceProvider"
```

Or publish individually:

```
# 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
```

### Step 3: Run Migrations

[](#step-3-run-migrations)

```
php artisan migrate
```

This will create:

- `calls` table - Stores call records
- Add device-related columns to `users` table (device\_token, device\_platform, is\_online, last\_seen)

Configuration
-------------

[](#configuration)

### Step 1: Add ZegoCloud Credentials to `.env`

[](#step-1-add-zegocloud-credentials-to-env)

```
# ZegoCloud Configuration
ZEGOCLOUD_APP_ID=your_app_id_here
ZEGOCLOUD_SERVER_SECRET=your_server_secret_here

# Push Notifications (Optional - for mobile apps)
ZEGO_PUSH_NOTIFICATIONS_ENABLED=true

# FCM Configuration (Android)
FCM_SERVER_KEY=your_fcm_server_key

# APNs Configuration (iOS)
APN_KEY_ID=your_apn_key_id
APN_TEAM_ID=your_apple_team_id
APN_BUNDLE_ID=com.yourapp.bundleid
APN_KEY_PATH=/path/to/AuthKey.p8
APN_PRODUCTION=false

# Broadcasting Configuration
BROADCAST_DRIVER=pusher
PUSHER_APP_ID=your_pusher_app_id
PUSHER_APP_KEY=your_pusher_key
PUSHER_APP_SECRET=your_pusher_secret
PUSHER_APP_CLUSTER=your_cluster

# Optional Settings
ZEGO_MAX_CALL_DURATION=3600
ZEGO_AUTO_END_MISSED_CALLS=true
ZEGO_MISSED_CALL_TIMEOUT=60
```

### Step 2: Get Your ZegoCloud Credentials

[](#step-2-get-your-zegocloud-credentials)

1. Go to [ZegoCloud Console](https://console.zegocloud.com)
2. Create a new project or select existing one
3. Get your App ID and Server Secret from the project settings

That's it! The package is now ready to use.

Usage
-----

[](#usage)

### Web Integration

[](#web-integration)

#### Basic Implementation

[](#basic-implementation)

Add call buttons to your Blade template:

```

@auth

            📹 Video Call

            📞 Audio Call

        const csrfToken = '{{ csrf_token() }}';

        function initiateVideoCall(userId) {
            ZegoCloudCaller.initiateCall(userId, 'video', csrfToken);
        }

        function initiateAudioCall(userId) {
            ZegoCloudCaller.initiateCall(userId, 'audio', csrfToken);
        }

@endauth
```

#### Using Helper Methods

[](#using-helper-methods)

Or use the built-in button creators:

```

    const csrfToken = '{{ csrf_token() }}';
    const userId = {{ $user->id }};
    const callButtons = document.getElementById('call-buttons');

    // Add video call button
    callButtons.appendChild(
        ZegoCloudCaller.createVideoCallButton(userId, csrfToken)
    );

    // Add audio call button
    callButtons.appendChild(
        ZegoCloudCaller.createAudioCallButton(userId, csrfToken)
    );

```

#### Programmatic Call Initiation

[](#programmatic-call-initiation)

You can also initiate calls programmatically via AJAX:

```
// Initiate video call
fetch('/call/initiate', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'X-CSRF-TOKEN': csrfToken
    },
    body: JSON.stringify({
        receiver_id: userId,
        call_type: 'video'
    })
})
.then(response => response.json())
.then(data => {
    if (data.success) {
        window.location.href = data.room_url;
    }
});
```

### API Integration

[](#api-integration)

The package provides RESTful API endpoints for both web and mobile applications.

#### Web API Endpoints

[](#web-api-endpoints)

Base URL: `/api/call` (requires authentication via Sanctum)

```
POST   /api/call/initiate            # Initiate a new call
POST   /api/call/{call}/accept       # Accept an incoming call
POST   /api/call/{call}/reject       # Reject an incoming call
POST   /api/call/{call}/end          # End an active call
GET    /api/call/{call}/details      # Get call details
POST   /api/call/generate-token      # Generate ZegoCloud token
```

#### Mobile API Endpoints

[](#mobile-api-endpoints)

Base URL: `/api/mobile/call` (requires authentication via Sanctum)

```
POST   /api/mobile/call/register-device                # Register device for push notifications
POST   /api/mobile/call/update-online-status           # Update user online status
POST   /api/mobile/call/initiate                       # Initiate a call
POST   /api/mobile/call/{callId}/accept                # Accept a call
POST   /api/mobile/call/{callId}/reject                # Reject a call
POST   /api/mobile/call/{callId}/end                   # End a call
GET    /api/mobile/call/active-calls                   # Get active calls
GET    /api/mobile/call/call-history                   # Get call history
GET    /api/mobile/call/{callId}/details               # Get call details
GET    /api/mobile/call/user/{userId}/availability     # Check user availability
POST   /api/mobile/call/generate-token                 # Generate token
```

#### Example: Initiate Call (API)

[](#example-initiate-call-api)

```
// 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"
}
```

Mobile App Integration
----------------------

[](#mobile-app-integration)

For mobile app integration (iOS/Android), see the comprehensive guide:

**[📱 Mobile Integration Guide](MOBILE_INTEGRATION.md)**

The mobile integration guide includes:

- Complete Android (Kotlin) implementation
- Complete iOS (Swift) implementation
- Push notification setup for both platforms
- WebSocket integration for real-time updates
- ZegoCloud SDK integration
- Code examples and best practices

### Quick Start for Mobile Developers

[](#quick-start-for-mobile-developers)

1. **Register Device**:

```
POST /api/mobile/call/register-device
{
    "device_token": "fcm_or_apn_device_token",
    "device_platform": "android" // or "ios"
}
```

2. **Listen for Incoming Calls** via:

    - Push notifications (when app is in background)
    - WebSocket events (when app is active)
3. **Accept/Reject Calls**:

```
POST /api/mobile/call/{callId}/accept
POST /api/mobile/call/{callId}/reject
```

4. **Join ZegoCloud Room** using the provided configuration in the response

Customization
-------------

[](#customization)

### Customizing Routes

[](#customizing-routes)

Edit `config/zego-calling.php`:

```
'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'],
    ],
],
```

### Customizing the UI

[](#customizing-the-ui)

Publish the views:

```
php artisan vendor:publish --tag=zego-calling-views
```

Then edit the views in `resources/views/vendor/zego-calling/`.

### Customizing the User Model

[](#customizing-the-user-model)

In `config/zego-calling.php`:

```
'user_model' => App\Models\User::class,
```

### Call Settings

[](#call-settings)

```
'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
],
```

Broadcasting Setup
------------------

[](#broadcasting-setup)

The package uses Laravel Broadcasting for real-time call state synchronization. You need to configure broadcasting in your Laravel application.

### Step 1: Install Laravel Echo and Pusher

[](#step-1-install-laravel-echo-and-pusher)

```
npm install --save-dev laravel-echo pusher-js
```

### Step 2: Configure Broadcasting

[](#step-2-configure-broadcasting)

In `resources/js/bootstrap.js`:

```
import Echo from 'laravel-echo';
import Pusher from 'pusher-js';

window.Pusher = Pusher;

window.Echo = new Echo({
    broadcaster: 'pusher',
    key: import.meta.env.VITE_PUSHER_APP_KEY,
    cluster: import.meta.env.VITE_PUSHER_APP_CLUSTER,
    forceTLS: true
});
```

### Step 3: Listen for Call Events

[](#step-3-listen-for-call-events)

```
// Listen for incoming calls
Echo.private(`user.${userId}`)
    .listen('.call.initiated', (e) => {
        console.log('Incoming call from:', e.caller.name);
        // Show incoming call notification
        showIncomingCallNotification(e);
    })
    .listen('.call.accepted', (e) => {
        console.log('Call accepted');
        // Join call room
    })
    .listen('.call.rejected', (e) => {
        console.log('Call rejected');
        // Show rejection message
    })
    .listen('.call.ended', (e) => {
        console.log('Call ended');
        // Close call interface
    });
```

Testing
-------

[](#testing)

Run the package tests:

```
composer test
```

Or run specific test suites:

```
# Test call initiation
php artisan test --filter CallInitiationTest

# Test mobile API
php artisan test --filter MobileApiTest
```

Troubleshooting
---------------

[](#troubleshooting)

### Calls Not Connecting

[](#calls-not-connecting)

1. **Check ZegoCloud Credentials**: Ensure `ZEGOCLOUD_APP_ID` and `ZEGOCLOUD_SERVER_SECRET` are correct in `.env`
2. **Verify Broadcasting Setup**: Make sure Laravel Echo is properly configured
3. **Check Firewall**: Ensure WebSocket ports are open

### Push Notifications Not Working

[](#push-notifications-not-working)

1. **FCM (Android)**:

    - Verify `FCM_SERVER_KEY` in `.env`
    - Check device token registration
    - Ensure Firebase is properly configured in your mobile app
2. **APNs (iOS)**:

    - Verify all APN credentials are correct
    - Ensure certificates are not expired
    - Check bundle ID matches

### WebSocket Connection Fails

[](#websocket-connection-fails)

1. Check `.env` broadcasting configuration
2. Verify Pusher credentials
3. Ensure Laravel Echo is imported and initialized
4. Check browser console for connection errors

### Video/Audio Not Working

[](#videoaudio-not-working)

1. **Check Browser Permissions**: Ensure camera/microphone access is granted
2. **HTTPS Required**: ZegoCloud requires HTTPS in production
3. **Check Device Compatibility**: Verify browser supports WebRTC

Upgrade Guide
-------------

[](#upgrade-guide)

### From 1.x to 2.x

[](#from-1x-to-2x)

```
# Backup your database
php artisan backup:run

# Update package
composer update mainul12501/zego-audio-video-calling

# Publish new assets
php artisan vendor:publish --tag=zego-calling-config --force

# Run migrations
php artisan migrate

# Clear cache
php artisan config:clear
php artisan view:clear
```

Contributing
------------

[](#contributing)

Contributions are welcome! Please feel free to submit a Pull Request.

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

Security
--------

[](#security)

If you discover any security-related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Mainul Hassan](https://github.com/Mainul12501)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

Support
-------

[](#support)

- 📧 Email:
- 🐛 Issues: [GitHub Issues](https://github.com/Mainul12501/zego-audio-video-calling/issues)
- 📖 Documentation: [Full Documentation](https://github.com/Mainul12501/zego-audio-video-calling/wiki)
- 💬 Discussions: [GitHub Discussions](https://github.com/Mainul12501/zego-audio-video-calling/discussions)

---

Made with ❤️ by [Mainul Islam](https://github.com/Mainul12501)

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance71

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

162d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5ff09c9d3ceaf957dae0f365749477680c0eb6d8d7ada9bcc266e3d4b53552a0?d=identicon)[Mainul12501](/maintainers/Mainul12501)

---

Top Contributors

[![Mainul12501](https://avatars.githubusercontent.com/u/45430222?v=4)](https://github.com/Mainul12501 "Mainul12501 (5 commits)")

---

Tags

laravelWebRTCzegocloudvideo-callingaudio-callingreal-time-communicationmobile-integration

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mainul12501-zego-audio-video-calling/health.svg)

```
[![Health](https://phpackages.com/badges/mainul12501-zego-audio-video-calling/health.svg)](https://phpackages.com/packages/mainul12501-zego-audio-video-calling)
```

###  Alternatives

[spatie/laravel-health

Monitor the health of a Laravel application

85810.0M83](/packages/spatie-laravel-health)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[laravel/cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

264778.4k3](/packages/laravel-cashier-paddle)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
