marcelog/pagi
Composer 安装命令:
composer require marcelog/pagi
包简介
Asterisk Gateway Interface (AGI) client for PHP, suitable to make telephony applications using call flow nodes
README 文档
README
Introduction
This framework is intended to simply making ivr applications using Asterisk's AGI, providing a nice level of abstraction over what an IVR should look like from a developers' perspective.
Documentation
- Main Site
- API
- Complete PAGI/PAMI talk for the PHP Conference Argentina 2013. Check the slide notes for the complete text :)
- In-depth tutorial
- An example IVR application that includes unit tests is available here
- Professional Telephony Applications at hand The march edition of Software Developer Journal features a complete article about writing telephony applications with PAMI and PAGI.
Installing
Add this library to your Composer configuration. In composer.json:
"require": { "marcelog/pagi": "2.*" }
Using it
First, make sure you include the autoloader shipped with composer:
require __DIR__ . '/vendor/autoload.php';
Quickstart
You can start by doc/examples/quickstart for a very basic example. You'll need something like this in your dialplan:
[default]
exten => 1,1,AGI(/path/to/PAGI/doc/examples/quickstart/run.sh,a,b,c,d)
exten => 1,n,Hangup
Testing IVR applications
A mocked pagi client is included to easily test your ivr applications. See doc/examples/mock to see an example of how to use it.
Features
Nodes
For a tutorial about nodes, see this article
Simple Call Flow Nodes are available (see doc/examples/node/example.php). Using nodes will let you simplify how you build and test your ivr applications. Nodes are an abstraction layer above the pagi client, and support:
- Prompts mixing sound files, playing numbers/digits/datetime's.
- Cancel and End Of Input digits.
- Validator callbacks for inputs, can optionally specify 1 or more sound files to play when the validation fails.
- Callbacks for invalid and valid inputs.
- Optional sound when no input.
- Maximum valid input attempts.
- Optional sound when maximum attempts has been reached.
- Expecting at least/at most/exactly N digits per input.
- Timeout between digits in more-than-1 digit inputs.
- Timeout per input attempt.
- Retry Attempts for valid inputs.
- And much more!
The NodeController will let you control the call flow of your application, by registering nodes and actions based on node results. Thus, you can jump from one node to the other on cancel or complete inputs, hangup the call, execute a callback, etc. For an example, see doc/examples/nodecontroller/example.php
An article about the node controller is available here
AutoDial
CallFiles are supported. You can also schedule a call in the future.
Fax
Sending and receiving faxes is supported using spandsp (applications SendFax and ReceiveFax).
Available Facades
- PAGI\Client\CDR: Provided to access cdr variables.
- PAGI\Client\ChannelVariables: Provided to access channel variables and asterisk environment variables.
- PAGI\Client\CallerID: Provided to access caller id variables.
- PAGI\Client\Result: Provided to wrap up the result for agi commands.
- PAGI\CallSpool\CallFile: Call file facade.
- PAGI\CallSpool\CallSpool: Call spool facade.
- PAGI\Logger\Asterisk: Provides access to asterisk logger (see logger.conf in your asterisk installation).
Results
For every operation, a Result is provided. Some operations decorate this Result to add functionality, like PlayResult, ReadResult, etc. For example, a stream file will return a PlayResult, which decorates a ReadResult which in turn, decorated a Result.
- PAGI\Client\DialResult
- PAGI\Client\ExecResult
- PAGI\Client\ReadResult
- PAGI\Client\PlayResult
- PAGI\Client\FaxResult
Debugging, logging
You can optionally set a PSR-3 compatible logger:
$pagi->setLogger($logger);
By default, the client will use the NullLogger.
Developers
This project uses phing. Current tasks include:
- test: Runs PHPUnit.
- cs: Runs CodeSniffer.
- doc: Runs PhpDocumentor.
- md: runs PHPMD.
- build: This is the default task, and will run all the other tasks.
Running a phing task
To run a task, just do:
vendor/bin/phing build
Contributing
To contribute:
- Make sure you open a concise and short pull request.
- Throw in any needed unit tests to accomodate the new code or the changes involved.
- Run
phingand make sure everything is ok before submitting the pull request (make phpmd and CodeSniffer happy, also make sure that phpDocumentor does not throw any warnings, since all our documentation is automatically generated). - Your code must comply with PSR-2, CodeSniffer should take care of that.
LICENSE
Copyright 2011 Marcelo Gornstein marcelog@gmail.com
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
marcelog/pagi 适用场景与选型建议
marcelog/pagi 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 137.39k 次下载、GitHub Stars 达 190, 最近一次更新时间为 2012 年 08 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「flow」 「client」 「node」 「asterisk」 「voip」 「agi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 marcelog/pagi 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 marcelog/pagi 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 marcelog/pagi 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Put images nicley in a row
Create link to static resources with cache-breaking segment based on md5 of the file
getting and sending flow
Mock PSR-18 HTTP client
This package provides your visitors the possibility to comment stuff and discuss together.
Asynchronous MQTT client built on React
统计信息
- 总下载量: 137.39k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 192
- 点击次数: 30
- 依赖项目数: 21
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2012-08-30