承接 voipforall/laravel-asterisk-ari 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

voipforall/laravel-asterisk-ari

Composer 安装命令:

composer require voipforall/laravel-asterisk-ari

包简介

Laravel integration for Asterisk REST Interface (ARI)

README 文档

README

Laravel Asterisk ARI

Latest Version on Packagist Total Downloads GitHub Actions

An opinionated Laravel package for managing Asterisk PBX through the Asterisk REST Interface (ARI).

Requirements

  • PHP ^8.2
  • Laravel 11, 12 or 13

Installation

composer require voipforall/laravel-asterisk-ari

Publish the configuration file:

php artisan vendor:publish --tag=asterisk-config

Configuration

Add the following variables to your .env file:

ASTERISK_ARI_HOST=127.0.0.1
ASTERISK_ARI_PORT=8088
ASTERISK_ARI_USER=asterisk
ASTERISK_ARI_PASSWORD=your-secret
ASTERISK_ARI_APP=laravel
ASTERISK_ARI_SCHEME=http
ASTERISK_ARI_WS_SCHEME=ws
ASTERISK_ARI_TIMEOUT=10
Variable Description Default
ASTERISK_ARI_HOST Asterisk server IP or hostname 127.0.0.1
ASTERISK_ARI_PORT ARI HTTP port 8088
ASTERISK_ARI_USER ARI username asterisk
ASTERISK_ARI_PASSWORD ARI password (required)
ASTERISK_ARI_APP Stasis application name laravel
ASTERISK_ARI_SCHEME HTTP scheme (http or https) http
ASTERISK_ARI_WS_SCHEME WebSocket scheme (ws or wss) ws
ASTERISK_ARI_TIMEOUT HTTP request timeout in seconds 10

Usage

You can use the Ari facade or inject AriManager directly:

use VoIPforAll\AsteriskAri\Facades\Ari;

// Via facade
$channels = Ari::channels()->list();

// Via injection
use VoIPforAll\AsteriskAri\AriManager;

public function __construct(private AriManager $ari) {}

public function index()
{
    return $this->ari->channels()->list();
}

API Reference

Channels

Manage active channels (calls) on Asterisk.

use VoIPforAll\AsteriskAri\Facades\Ari;

List all channels

Ari::channels()->list();

Get channel details

Ari::channels()->get(string $channelId);

Originate a call

Ari::channels()->originate(
    endpoint: 'PJSIP/1000',
    extension: '1001',
    context: 'default',
    callerId: '"John" <1000>',
    timeout: 30,
    app: 'laravel',
);
Parameter Type Required Description
endpoint string Yes Target endpoint (e.g. PJSIP/1000)
extension ?string No Extension to dial
context ?string No Dialplan context
callerId ?string No Caller ID string
timeout ?int No Dial timeout in seconds
app ?string No Stasis application to place channel into

Hangup a channel

Ari::channels()->hangup(string $channelId, string $reason = 'normal');

Answer a channel

Ari::channels()->answer(string $channelId);

Hold / Unhold

Ari::channels()->hold(string $channelId);
Ari::channels()->unhold(string $channelId);

Mute / Unmute

Ari::channels()->mute(string $channelId, string $direction = 'both');
Ari::channels()->unmute(string $channelId, string $direction = 'both');

The $direction parameter accepts: both, in, or out.

Channel Variables

Ari::channels()->getVariable(string $channelId, string $variable);
Ari::channels()->setVariable(string $channelId, string $variable, string $value);

Send DTMF

Ari::channels()->sendDtmf(string $channelId, string $dtmf);

Record a channel

Ari::channels()->record(string $channelId, string $name, string $format = 'wav');

Bridges

Manage bridges (conference rooms, call mixing).

List all bridges

Ari::bridges()->list();

Get bridge details

Ari::bridges()->get(string $bridgeId);

Create a bridge

Ari::bridges()->create(string $type = 'mixing', ?string $name = null);

Bridge types: mixing, holding, dtmf_events, proxy_media.

Destroy a bridge

Ari::bridges()->destroy(string $bridgeId);

Add channels to a bridge

// Single channel
Ari::bridges()->addChannel(bridgeId: '1234', channels: 'channel-id');

// Multiple channels
Ari::bridges()->addChannel(bridgeId: '1234', channels: ['channel-1', 'channel-2']);

Remove channels from a bridge

Ari::bridges()->removeChannel(bridgeId: '1234', channels: 'channel-id');
Ari::bridges()->removeChannel(bridgeId: '1234', channels: ['channel-1', 'channel-2']);

Endpoints

Query registered endpoints (SIP/PJSIP peers).

List all endpoints

Ari::endpoints()->list();

List by technology

Ari::endpoints()->listByTechnology(string $technology);

// Example
Ari::endpoints()->listByTechnology('PJSIP');

Get a specific endpoint

Ari::endpoints()->get(string $technology, string $resource);

// Example
Ari::endpoints()->get('PJSIP', '1000');

Device States

Manage custom device states.

List all device states

Ari::deviceStates()->list();

Get device state

Ari::deviceStates()->get(string $deviceName);

Update device state

Ari::deviceStates()->update(string $deviceName, string $state);

Valid states: NOT_INUSE, INUSE, BUSY, INVALID, UNAVAILABLE, RINGING, RINGINUSE, ONHOLD.

Delete device state

Ari::deviceStates()->delete(string $deviceName);

Recordings

Manage stored and live recordings.

Stored Recordings

Ari::recordings()->listStored();
Ari::recordings()->getStored(string $name);
Ari::recordings()->deleteStored(string $name);

Live Recordings

Ari::recordings()->getLive(string $name);
Ari::recordings()->stop(string $name);
Ari::recordings()->pause(string $name);
Ari::recordings()->unpause(string $name);

Asterisk

Query Asterisk system information.

Get system info

// All info
Ari::asterisk()->info();

// Filtered (build, system, config, status)
Ari::asterisk()->info(only: 'system');

Ping

Ari::asterisk()->ping(); // Returns true if Asterisk is reachable

Get global variable

Ari::asterisk()->getVariable(string $variable);

WebSocket Events

Listen to real-time ARI events using the built-in Artisan command:

php artisan ari:listen

The command connects to Asterisk via WebSocket with automatic reconnection (exponential backoff up to 60s). Use SIGTERM or SIGINT (Ctrl+C) for graceful shutdown.

Supported Events

All events are dispatched as standard Laravel events. Register listeners in your EventServiceProvider or use the Event facade:

ARI Event Laravel Event Class
StasisStart VoIPforAll\AsteriskAri\Events\StasisStart
StasisEnd VoIPforAll\AsteriskAri\Events\StasisEnd
ChannelCreated VoIPforAll\AsteriskAri\Events\ChannelCreated
ChannelDestroyed VoIPforAll\AsteriskAri\Events\ChannelDestroyed
ChannelStateChange VoIPforAll\AsteriskAri\Events\ChannelStateChange
ChannelEnteredBridge VoIPforAll\AsteriskAri\Events\ChannelEnteredBridge
ChannelLeftBridge VoIPforAll\AsteriskAri\Events\ChannelLeftBridge
BridgeCreated VoIPforAll\AsteriskAri\Events\BridgeCreated
BridgeDestroyed VoIPforAll\AsteriskAri\Events\BridgeDestroyed
DeviceStateChanged VoIPforAll\AsteriskAri\Events\DeviceStateChanged

Listening to Events

// In a Listener class
use VoIPforAll\AsteriskAri\Events\StasisStart;

class HandleIncomingCall
{
    public function handle(StasisStart $event): void
    {
        $channel = $event->getChannel();
        $args = $event->getArgs();

        // Handle the incoming call...
    }
}

Every event extends AriEvent and provides:

$event->payload;          // Full raw payload from ARI
$event->getType();        // Event type string
$event->getTimestamp();   // Event timestamp
$event->getApplication(); // Stasis application name

Registering Custom Events

You can register additional ARI event types:

use VoIPforAll\AsteriskAri\Events\EventFactory;

EventFactory::register('PlaybackFinished', \App\Events\PlaybackFinished::class);

The custom event class must extend VoIPforAll\AsteriskAri\Events\AriEvent.

Testing

composer test

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security related issues, please email cristiano@voipforall.com.br instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

voipforall/laravel-asterisk-ari 适用场景与选型建议

voipforall/laravel-asterisk-ari 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 03 月 29 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「asterisk」 「laravel」 「voip」 「ARI」 「pbx」 「pjsip」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 voipforall/laravel-asterisk-ari 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 voipforall/laravel-asterisk-ari 我们能提供哪些服务?
定制开发 / 二次开发

基于 voipforall/laravel-asterisk-ari 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-29