welltime / phpagi

PHPAGI is a PHP class for the Asterisk Gateway Interface. The package is available for use and distribution under the terms of the GNU Public License.
GNU Lesser General Public License v2.1
58 stars 93 forks source link

Difficulties on how to use. Namespace? #19

Open Terumi opened 6 years ago

Terumi commented 6 years ago

Hello people. I'm trying to use this project (having loaded through composer) but I cannot reference the classes properly as they do not have a namespace. I'm I doing something wrong?

Warmbellycat commented 6 years ago

Hello @Terumi! Just use:

require_once './vendor/autoload.php';
$agi = new \Agi($yourConfigFileName);
//or $agi = new \Agi(null, $configArray);
//or $ami = new \AGI_AsteriskManager($yourConfigFileNam);
//or $ami = new \AGI_AsteriskManager(null, $configArray);

You can find configuration file example in phpagi/docs folder. If you want to use configuration array - parameters must have same names as in config file.

$configArray = [
    'server'=>'hostname or ip of your asterisk server', 
    'port'=>5038, /*asterisk manager port, integer*/
    'username'=>'your_asterisk_manager_username',
    'secret'=>'your_asterisk_manager_password'
];