ritch / ami-monitor
There is no license information available for the latest version (v1.1) of this package.
v1.1
2021-01-22 01:24 UTC
Requires
- wisembly/elephant.io: ^3.3
This package is auto-updated.
Last update: 2025-04-22 11:44:24 UTC
README
This is a new colaboration of asterisk AMI with PHP.
Donate
Help this project grow. Has many things to improve.
Instalation
Via Composer just run composer require ritch/ami-monitor
or clone this repository via Github.
Run composer install
if you cloned the project by git directly
Run npm install
I Will improve this code and this explication, I swear,
but if you only read this code, mainly monitorManager.php
or run php monitorManager.php
, You can use.
Configuration
- Copy the
config.ini.sample
toconfig.ini
and put your configs
To Run
- If you want use web socket, run
node webSocketServer.js
, dont forget to put the configuration inconfig.ini
. - Copy samples to your base directory
cp -rf vendor/ritch/ami-monitor/samples .
or make your self monitor. - Run
php samples/monitorManager.php
- Has a file
index.html
in samples folder, if you has using web socket, and all right, you'll start receive the events on your web page.
Custom File monitor example:
<?php namespace App; //The path of autoload include 'vendor/autoload.php'; use App\WebSocket; use App\Ami; set_time_limit(0); $webSocket = new WebSocket(); $ami = new Ami(); //Filter some events or show All; $event = [ 'All', /*'AgentLogin', 'Hangup', 'BridgeEnter', 'AgentConnect', */ ]; do { switch ( @$amiEvent->Event ) { //If you has filtering some event, here you can do your logic, or send to websocket, case "Hangup": // You code here. $amiEvent = $ami->getEvent($event); $webSocket->emit( "MyCustomAction", [ $amiEvent ] ); print_r($amiEvent); break; case "AgentConnect": // You code here. break; default: $amiEvent = $ami->getEvent($event); $webSocket->emit( "ami", [ $amiEvent ] ); print_r($amiEvent); break; } } while ( Utils::check_asterisk_status() ); ?>
Donate
Help this project grow. Has many things to improve.