1. Go to this page and download the library: Download fperdomo/php-agi 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/ */
fperdomo / php-agi example snippets
#!/usr/bin/env php
declare(strict_types=1);
();
// Answer the call
$agi->answer();
// Speak text using text-to-speech
$agi->text2wav("Hello from PHPAGI!");
// Hangup the call
$agi->hangup();
exit(0);
} catch (\Throwable $e) {
// Log errors to stderr for debugging
error_log('AGI Error: ' . $e->getMessage());
exit(1);
}
declare(strict_types=1);
atcher;
// Handler scripts live here
$dispatcher = new FastAgiDispatcher(
baseDir: __DIR__ . '/handlers',
dropPrivileges: true,
logVerboseDump: false,
);
$dispatcher->handle();
bash
# Make executable
chmod +x examples/agi/interactive-menu.php
# Copy to Asterisk AGI directory
cp examples/agi/interactive-menu.php /var/lib/asterisk/agi-bin/
# Add to extensions.conf
# exten => 123,1,AGI(interactive-menu.php)
bash
# Set environment variables
export AMI_HOST="127.0.0.1"
export AMI_USER="admin"
export AMI_SECRET="your-secret"
# Run the example
php examples/ami/ping.php
bash
# Start the FastAGI server
php examples/fastagi/server.php
# In extensions.conf:
# exten => 123,1,FastAGI(agi://127.0.0.1:4573/your-script)
src/
Agi.php # Main AGI class
FastAgiDispatcher.php # FastAGI dispatcher
AgiAsteriskManager.php# Asterisk Manager (AMI) support
composer.json
README.md
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.