{"id":20365920,"url":"https://github.com/cycoresystems/asterisk-php-libs","last_synced_at":"2026-05-07T21:45:26.235Z","repository":{"id":4503899,"uuid":"5643368","full_name":"CyCoreSystems/asterisk-php-libs","owner":"CyCoreSystems","description":"PHP Classes for Asterisk AMI and AGI interfacing","archived":false,"fork":false,"pushed_at":"2012-09-03T20:46:23.000Z","size":128,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-25T15:03:42.529Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CyCoreSystems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-09-01T21:12:00.000Z","updated_at":"2024-10-31T18:18:02.000Z","dependencies_parsed_at":"2022-09-18T04:26:39.727Z","dependency_job_id":null,"html_url":"https://github.com/CyCoreSystems/asterisk-php-libs","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fasterisk-php-libs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fasterisk-php-libs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fasterisk-php-libs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CyCoreSystems%2Fasterisk-php-libs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CyCoreSystems","download_url":"https://codeload.github.com/CyCoreSystems/asterisk-php-libs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241907685,"owners_count":20040507,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T00:21:10.728Z","updated_at":"2026-05-07T21:45:21.203Z","avatar_url":"https://github.com/CyCoreSystems.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"asterisk-php-libs\n=================\n\nPHP Classes for Asterisk AMI and AGI interfacing\n\nagi.php (class AGI)\n===================\n\nA simple class for building AGI-based PHP applications.  Loads AGI variables into the class object.  \n\nThe script may optionally be set to NOT end (default: end) on hangup by setting the PHP global variable `$GLOBALS['agi_end_on_hangup']` to boolean `false`.  Note that this is handled by attaching to SIGHUP, so if your application already handles or uses this signal, you'll have problems.\n\nread ()\n------------------------\n\nReads reads a line from stdin (Asterisk).  The return value is an associative array with:\n* 'raw': the full, unparsed response from Asterisk\n* 'code': the three-digit response code from Asterisk\n* 'result': the command-specific numeric result code\n* 'data': the command-specific data from Asterisk\n\nwrite ( $line )\n---------------\n\nWrites a(n otherwise unformatted) line to stdout (Asterisk).\n\ngetVar ( $varname, [ `$exception_on_empty = FALSE` ] )\n-------------------\n\nRequests the value of a (channel) variable and returns it.  If the second (optional) argument is set to TRUE, an exception will be thrown if the variable is undefined (so NULL values can be differentiated).\n\nsetVar ( $varname, [ $varval = 0 ] )\n------------------------------------\n\nSets or creates a variable with the value given by the second argument.  If there is no second argument defines, then the variable is set to 0.\n\ngetDB ( $family, $key, [ `$exception_on_empty = FALSE` ] )\n----------------------------------------------------------\n\nRequests the value of a (channel) variable and returns it.  If the third (optional) argument is set to TRUE, an exception will be thrown if the database key is undefined (so NULL values can be differentiated).\n\nsetDB ( $varname, [ $varval = 0 ] )\n------------------------------------\n\nSets or creates a variable with the value given by the second argument.  If there is no second argument defines, then the variable is set to 0.\n\n### The following methods are specific macros for commonly-executed actions\n\nverbose ( $line, [ $level = 1 ] )\n---------------------------------\n\nSends the Verbose AGI command with the first argument as the content.  The optional second argument is the verbose level (default: 1) to set.\n\nanswer ()\n---------\n\nTells Asterisk to answer the call/channel\n\nhangup ()\n---------\n\nTells Asterisk to hangup the call/channel\n\n\nami.php (class AMI)\n===================\n\nA simple class for building AMI-based PHP applications.\n\nThe host (or IP) for the Asterisk box may be passed as an argument to the class constructor, can be read from the PHP global `$GLOBALS['AMIHost']`, or passed as the first argument to AMI::login.  The port number is hard-coded to the standard 5038, but exists in only one place, so it can be easily changed, as needed.\n\nNote on use:  The AMI sends multiple lines of key-value pairs back and forth with each command-response dialog.  In order to maximize flexibility of each, these pairs are parsed and stored in class variables.  This makes commands easy to construct and results easy to parse, but mandates that you \"clear\" these variables between dialogs.  Hence, between each command, you should call `AMI::clear()`\n\nErrors are handled by exception throws.\n\nlogin( $host, $username, $password )\n------------------------------------\n\nLog into the AMI interface of Asterisk.  This method must be called before any other communication methods are available.\n\nAll arguments are optional. \n- `host` will be pulled from the class variable 'host' (which may have been set during instantiation by parameter or PHP global 'AMIHost').\n- `username` will be pulled from the PHP global `$GLOBALS['AMIUser']` if not supplied\n- `password` will be pulled from the PHP global `$GLOBALS['AMIPass']` if not supplied\n\n\nlogout ()\n---------\n\nExplicitly log out from an AMI session.\n\n\nclear ()\n--------\n\nAMI requests, results, and variables are stored as class variable arrays.  Hence, between each communication, this method should be called to reset these variables to null arrays.\n\naddVar ( $key, $val )\n---------\n\nAdds a Variable to the pending AMI dialog. (Interpreted in AMI as `Variable: $key=$val`)\n\naddReq ( $key, $val )\n---------------------\n\nAdds a request to the pending AMI dialog. (Interpreted in AMI as `$key: $val`)\n\nsetReq ( $key, $val )\n---------------------\n\nAdds a request to the pending AMI dialog, replacing the given key if it already exists.\n\nexecute ()\n----------\n\nSend the pending AMI dialog request (and load the response into the `AMI::amires` class variable).\n\nsend ()\n-------\n\nSend the pending AMI dialog request (only)... this should probably never be called directly: use `AMI::execute()`.\n\nread( [ $maxlines = NULL ], [ $timeout = 15] )\n----------------------------------------------\n\nRead the response dialog from AMI... this should probably never be called directly: use `AMI::execute()`.\n\ngetRes ( $key )\n---------------\n\nReturn the result value whose key is `$key`\n\n\n### The following methods are specific macros for commonly-executed actions\n\nparkCall ( $chan )\n------------------\n\nPark the given channel.  Returns the 'Exten' variable of the call on success.\n\ngetParkedCalls ()\n-----------------\n\nReturns the list of parked calls.\n\ngetChannels ()\n--------------\n\nReturns the list of active channels.\n\nbestPRI ()\n----------\n\nReturns the span number of the least-loaded PRI.\n\ncheckPRI ( $span = 0 )\n-----------\n\nChecks the status of the given PRI span (default: 0).  Note:  this method only checks up to span 4.  If you have more than 4 spans, you'll need to change the `$max` (local method) variable.\n\ngetChannelsWith( $key, $val )\n-----------------------------\n\nReturns the list of active channels who have channel variables `$key` with values `$val`.\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycoresystems%2Fasterisk-php-libs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcycoresystems%2Fasterisk-php-libs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcycoresystems%2Fasterisk-php-libs/lists"}