taknone/phptgcalls 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

taknone/phptgcalls

Composer 安装命令:

composer require taknone/phptgcalls

包简介

A high-performance, non-blocking PHP library for Telegram Group Calls and WebRTC streaming via Rust

README 文档

README

PHP Extension Powered By Rust Telegram Calls

TgCalls PHP Extension

⚡ A blazing-fast PHP extension powered by Rust for Telegram voice/video calls ⚡

Stars Forks License Last Commit PHP 8.4+ Rust 1.96.0+

🎯 What is PhpTgCalls ?

PhpTgCalls is a native PHP extension built with Rust that brings Telegram voice & video calling capabilities directly into PHP. It wraps the powerful NTgCalls C++ library, providing a clean, object-oriented PHP API

It integrates seamlessly with LiveProto — the async, pure-PHP MTProto Telegram client — enabling you to join group calls, stream audio/video, and handle Telegram VoIP entirely from PHP

✨ Features

Category Feature
🎙️ Core Join group calls ( voice & video )
🎥 Media Stream audio/video with H.264, VP8, VP9, AV1, Opus, AAC, MP3
📺 Screen Screen sharing & presentation mode
🔄 Async Fully asynchronous — built for Fibers & Swoole
🔐 Crypto DH key exchange, encryption params, signaling
📡 Events Stream, connection, upgrade, frame, and signaling event streams
Performance Rust-powered native code, minimal overhead
🧩 Ecosystem First-class LiveProto integration

🏗️ Architecture

sequenceDiagram
    autonumber
    participant P as PHP (Application Layer)
    participant R as Rust Extension (Bridge)
    participant C as NTgCalls (C++ Core)

    Note over P, C: Initialization Phase
    P->>R: Instantiate TgcallsClient
    R-->>P: Return Native Instance Pointer
    P->>R: Enable Events (Initialize Buffer/FD)
    
    rect rgb(240, 248, 255)
        Note right of P: Request/Response Flow
        P->>R: Call Method (Payload)
        R->>C: FFI Bridge (WebRTC/Boost)
        C-->>R: Return Result
        R-->>P: Return Data to PHP
    end

    rect rgb(245, 245, 245)
        Note right of P: Async Event Handling (FD Mechanism)
        C->>R: Event Callback (Direct)
        R->>R: Write to File Descriptor (FD)
        loop Async Consumption
            P->>R: Read from FD Buffer
            R-->>P: Dispatch Event Object
        end
    end
Loading

📦 Installation

Prerequisites

  • PHP 8.4+
  • Rust 1.96.0+

From Source

git clone https://github.com/TakNone/phptgcalls.git
cd phptgcalls
cd ext

sudo bash install.sh

Verify Installation

php --ri phptgcalls

Composer

Note

Automated Rust extension installation and php.ini configuration :

composer require taknone/phptgcalls

Note

To install the framework package without triggering the automatic extension installation script, use :

composer require taknone/phptgcalls --no-scripts

🚀 Quick Start

<?php

require_once 'vendor/autoload.php';

use Tak\Liveproto\Utils\Settings;

use Tak\Liveproto\Network\Client;

use Tak\Tgcalls\Driver;

use Tak\Asyncio\Loop;

Loop::queue(static function() : void {
	try {
		$settings = new Settings();
		$settings->setApiId(21724);
		$settings->setApiHash('3e0cb5efcd52300aec5994fdfc5bdc16');
		$client = new Client('phptgcalls','sqlite',$settings);
		$client->start(false);

		$tgcalls = new Driver(client : $client,chat_id : -100123456789);
		$params_json = $tgcalls->create();

		// Both MTProto and TgCalls clients are ready to use... //
	} finally {
		$client->stop();
	}
});

Loop::run();

?>

🔗 Integration with LiveProto

TgCalls is designed to work hand-in-hand with LiveProto :

LiveProto TgCalls
MTProto connection & auth VoIP call management
phone.joinGroupCall() TgcallsClient.create() + connect()
DH config retrieval TgcallsClient.init_exchange()
Signaling relay TgcallsClient.send_signaling_data()

Important

LiveProto handles the MTProto layer ( Telegram API ), while TgCalls handles the WebRTC/VoIP layer. Together, they provide a complete Telegram calling solution in PHP

🧪 Examples

🤝 Contributing

We love contributions ! Here's how to get started :

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

💬 Community

Join the phptgcalls ecosystem :

Platform Link
💬 Telegram Chat PhpTgCallsChat
🐛 Bug Reports GitHub Issues

📜 License

This project is licensed under the MIT License

统计信息

  • 总下载量: 0
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 3
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 0
  • Forks: 0
  • 开发语言: Rust

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固