Asterisk PHP

Asterisk PHP (scripting within the dialplan)


Asterisk PHP allows you to control the dial-plan and write applications for Asterisk in PHP. This is faster and more flexible than phpAGI.
The PHP extensions can be found at

Function Reference

Documentation is a bit thin on the ground. Not all functions are covered below (See for a list of functions).

  • int asterisk_answer([string channel]): Answer a channel
  • int asterisk_best_codec([string channel])
  • int asterisk_bridge_call([string channel,] string peer[, array options])
  • array asterisk_chanlist(void)
  • int asterisk_channel_make_compatible([string channel,] string peer)
  • int asterisk_channel_setoption([string channel,] int option, string data)
  • int asterisk_channel_status([string channel])
  • int asterisk_cli(int fd, string cmd)
  • string asterisk_codec2str(int codec)
  • int asterisk_control_streamfile([string channel,] string file, string fwd, string rev, string stop, string pause[, int skipms])
  • int asterisk_db_del(string family, string keys)
  • int asterisk_db_deltree(string family[, string keytree])
  • int asterisk_db_get(string family, string keys)
  • int asterisk_db_put(string family, string keys, string value)
  • int asterisk_exec([string channel,] string app[, string data]): Execute an Asterisk application.
  • string asterisk_getdata([string channel,] string filename[, int maxdigits[, int timeout]])
  • int asterisk_getformatbyname(string name)
  • string asterisk_getformatname(int format)
  • int asterisk_get_priority([string channel])
  • string asterisk_get_variable([string channel,] string variable)
  • array asterisk_get_variables([string channel])
  • int asterisk_hangup([[string channel,] int cause])
  • asterisk_log(long log, string message)
  • int asterisk_manager_command(int fd, string cmd)
  • asterisk_moh_start([[string channel,] string class])
  • asterisk_moh_stop([string channel])
  • int asterisk_recvchar([[string channel,] int timeout])
  • string asterisk_request(string type, int format, string data, int &cause)
  • string asterisk_request_and_dial(string type, int format, string data, int timeoute, int outstate, string callerid)
  • int asterisk_say_character_str([string channel,] string chars, [string ints[, string lang]])
  • int asterisk_say_date([string channel,] [int time[, string ints[, string lang[, string format[, string timezone]]]]])
  • int asterisk_say_datetime([string channel,] [int time[, string ints[, string lang]]])
  • int asterisk_say_datetime_from_now([string channel,] [int time[, string ints[, string lang]]])
  • int asterisk_say_digit_str([string channel,] string digits, [string ints[, string lang="en"]])
  • int asterisk_say_number([string channel], int number, [string ints[, string lang[, string options]]])
  • int asterisk_say_phonetic_str([string channel,] string text[, string ints[, string lang]])
  • int asterisk_say_time([string channel,] [int time[, string ints[, string lang]]])
  • int asterisk_senddigit([string channel,] string digit)
  • int asterisk_send_image([string channel,] string image)
  • int asterisk_sendtext([string channel,] string text)
  • asterisk_set_best_read_format([string channel])
  • asterisk_set_best_write_format([string channel])
  • asterisk_set_callerid([string channel,] string callerid[, boolean anitoo])
  • int asterisk_set_context([string channel,] string context)
  • int asterisk_set_extension([string channel,] string exten)
  • int asterisk_set_priority([string channel,] int priority)
  • asterisk_set_read_format([string channel,] int format)
  • int asterisk_set_variable([string channel,] string variable, string value)
  • int asterisk_setwhentohangup([[string channel,] int timeout]): Automatically hang up after a timeout. Set timeout to -1 to disable.
  • asterisk_set_write_format([string channel,] int format)
  • string asterisk_state2str(int state)
  • int asterisk_stream_file([string channel,] string filename[, string digits[, int offset[, string lang]]])
  • int asterisk_tdd_mode([[string channel,] int mode])
  • asterisk_verbose(int level, string message)
  • asterisk_waitfor([string channel,] int wait)
  • int asterisk_waitfordigit([[string channel,] int timeout])

Created by: FireFury, Last modification: Thu 10 of Nov, 2005 (12:32 UTC)
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+