PHP code example of ofbeaton / phpami

1. Go to this page and download the library: Download ofbeaton/phpami library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ofbeaton / phpami example snippets


   $ami = new \PHPAMI\Ami();
   if ($ami->connect('localhost:5038', 'myuser', 'mysecret', 'off') === false) {
      throw new \RuntimeException('Could not connect to Asterisk Management Interface.');
   }
   
   // // if you have a looping of command function
   // // set allowTimeout flag to true
   // $ami->allowTimeout();

   // $result contains the output from the command
   $result = $ami->command('core show channels');
   
   $ami->disconnect();
bash
# Install Composer
curl -sS https://getcomposer.org/installer | php