PHPackages                             tico/phpagi - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tico/phpagi

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tico/phpagi
===========

PHP AGI client for Asterisk — modern PHP 8.x implementation

v1.0.3(3w ago)03LGPL-2.1-or-laterPHPPHP &gt;=8.1

Since Aug 14Pushed 3w agoCompare

[ Source](https://github.com/uribes78/phpagi)[ Packagist](https://packagist.org/packages/tico/phpagi)[ Docs](https://github.com/uribes78/phpagi)[ RSS](/packages/tico-phpagi/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependenciesVersions (9)Used By (0)

PHPAGI — Modern PHP 8.x Asterisk Gateway Interface
==================================================

[](#phpagi--modern-php-8x-asterisk-gateway-interface)

[![PHP Version](https://camo.githubusercontent.com/6616edde8a65eefafabbf872390d9f158f07816e76b0f5694ec2f4fb2a8ee7be/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344382e312d373737424234)](https://www.php.net/)[![License](https://camo.githubusercontent.com/f44f95a6941636b455498646104604d3d734165588d71d7c71246faa1994643e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4c47504c2d2d322e312d2d6f722d2d6c617465722d626c7565)](COPYING)

A modern, fully-typed PHP library for building Asterisk AGI applications. This is a complete overhaul of the legacy [phpagi](https://github.com/welltime/phpagi) library, rewritten for PHP 8.1+ with modern OOP practices, strict typing, and PSR-4 autoloading.

---

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

[](#installation)

```
composer require tico/phpagi
```

Quick Start
-----------

[](#quick-start)

```
use Phpagi\AgiClient;

$agi = new AgiClient();

$agi->answer();

$name = $agi->getVariable('CALLERID(name)');
$agi->sayNumber(1234);

$agi->hangup();
```

Architecture
------------

[](#architecture)

```
src/Phpagi/
├── AgiClient.php              # Main AGI client implementation
├── AgiInterface.php           # Contract interface
├── AgiRequest.php             # Immutable request DTO
├── AgiResponse.php            # Immutable response DTO
├── CallerId.php               # CallerID value object
├── ChannelState.php           # Backed enum for channel states
└── Exception/
    ├── AgiException.php       # Base exception
    └── ConnectionException.php # Stream errors

```

Full Example
------------

[](#full-example)

```
use Phpagi\AgiClient;
use Phpagi\CallerId;
use Phpagi\ChannelState;

$agi = new AgiClient();
$agi->answer();

$status = $agi->channelStatus();
$state = ChannelState::tryFromResult($status->result);

if ($state === ChannelState::Up) {
    $agi->streamFile('welcome');
    $input = $agi->getData('beep', 3000, 1);

    if ($input->digit() === '1') {
        $agi->execDial('SIP', '100', 30000);
    }
}

$cid = CallerId::parse($agi->getRequest()->callerId);
$agi->setVariable('CALLER_NAME', $cid->name);
$agi->hangup();
```

Changes from the Original (2.20)
--------------------------------

[](#changes-from-the-original-220)

Original (`phpagi.php`)Modern (`Phpagi\AgiClient`)Global functions, no namespacePSR-4 namespaced under `Phpagi\``var` properties, no type hintsTyped `readonly` DTOs, strict types everywhereReturns raw arrays: `['code'=>500, 'result'=>-1]`Throws `AgiException` on errorsArray access: `$agi->request['agi_callerid']`Typed object: `$agi->getRequest()->callerId`Global constants: `AST_STATE_UP`Backed enum: `ChannelState::Up``parse_callerid()` returns array`CallerId::parse()` returns typed value object`join()`, `substr()`, `strpos()``match`, `str_contains`, `str_starts_with`, `str_ends_with`Error codes in return valuesStructured exception hierarchyPHP 4 compatible syntaxPHP 8.1+ features: enums, union types, named arguments, property promotionPHP 8.x Features Used
---------------------

[](#php-8x-features-used)

- **Enums** — `ChannelState` backed enum replaces global integer constants
- **Readonly properties** — `AgiRequest`, `AgiResponse`, `CallerId` are immutable DTOs
- **Union types** — `string|int|float`, `string|false`, `AGI|false`
- **Named arguments** — Cleaner constructor/ method calls
- **Match expressions** — Replaces large `switch` blocks
- **String functions** — `str_contains()`, `str_starts_with()`, `str_ends_with()`
- **Null coalescing assignment** — `$config['key'] ??= 'default'`
- **Constructor property promotion**
- **`never` / `mixed` / `void` return types**

Documentation
-------------

[](#documentation)

Legacy documentation for the original API is preserved in `src/deprecated/` and `docs/`.

License
-------

[](#license)

LGPL-2.1-or-later. See [COPYING](COPYING).

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance95

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Every ~0 days

Total

4

Last Release

21d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e911cecb28b0f817fb5d2ea9d8b98ab1ce5d31f5b82f48e4582f7dd724dede45?d=identicon)[uribes78](/maintainers/uribes78)

---

Top Contributors

[![DmitryMCN](https://avatars.githubusercontent.com/u/24269581?v=4)](https://github.com/DmitryMCN "DmitryMCN (9 commits)")[![uribes78](https://avatars.githubusercontent.com/u/18754899?v=4)](https://github.com/uribes78 "uribes78 (9 commits)")[![FreeSS](https://avatars.githubusercontent.com/u/4200978?v=4)](https://github.com/FreeSS "FreeSS (4 commits)")[![alexeevdv](https://avatars.githubusercontent.com/u/597839?v=4)](https://github.com/alexeevdv "alexeevdv (4 commits)")[![sebastianberm](https://avatars.githubusercontent.com/u/6470150?v=4)](https://github.com/sebastianberm "sebastianberm (3 commits)")[![Arbuzov](https://avatars.githubusercontent.com/u/1662280?v=4)](https://github.com/Arbuzov "Arbuzov (2 commits)")[![Bdido86](https://avatars.githubusercontent.com/u/2090126?v=4)](https://github.com/Bdido86 "Bdido86 (1 commits)")[![ricventu](https://avatars.githubusercontent.com/u/3369838?v=4)](https://github.com/ricventu "ricventu (1 commits)")[![CodeLingoBot](https://avatars.githubusercontent.com/u/45469328?v=4)](https://github.com/CodeLingoBot "CodeLingoBot (1 commits)")[![nedlosster](https://avatars.githubusercontent.com/u/9947598?v=4)](https://github.com/nedlosster "nedlosster (1 commits)")[![ipoddubny](https://avatars.githubusercontent.com/u/1784421?v=4)](https://github.com/ipoddubny "ipoddubny (1 commits)")

---

Tags

asteriskvoiptelephonyphpagiagi

### Embed Badge

![Health badge](/badges/tico-phpagi/health.svg)

```
[![Health](https://phpackages.com/badges/tico-phpagi/health.svg)](https://phpackages.com/packages/tico-phpagi)
```

###  Alternatives

[marcelog/pagi

Asterisk Gateway Interface (AGI) client for PHP, suitable to make telephony applications using call flow nodes

191136.2k20](/packages/marcelog-pagi)[marcelog/pami

Asterisk Manager Interface (AMI) client for PHP, event driven, object oriented

418765.6k1](/packages/marcelog-pami)[chan-sccp/pami

Asterisk Manager Interface (AMI) client for PHP, event driven, object oriented (Fork)

2953.9k](/packages/chan-sccp-pami)[ofbeaton/phpami

Asterisk Manager Interface (AMI) for PHP 5.4+ supporting legacy v1.4 to v13 with no thrills.

1639.5k](/packages/ofbeaton-phpami)

PHPackages © 2026

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