An example of a PAGI IVR application, including unit tests
PHP Shell
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bin fixing paths, tests Jan 3, 2016
config.example fixing paths, tests Jan 3, 2016
src/MyApp updating to v2.0.0 Jan 3, 2016
test fixing paths, tests Jan 3, 2016
.gitignore updating to v2.0.0 Jan 3, 2016


An example PAGI IVR application (for asterisk and php, of course), including unit tests with phpunit. This is the source code for the article at:

The code

  • src/MyApp/App.php is the IVR application itself.
  • test/AppTest.php is a phpunit test case for the ivr application. It contains 2 unit tests.

The other files serve as a skeleton for running everything.


  1. Copy the directory "config.example" (and its contents) to "config".
  2. Edit config/php.ini if you need to change xdebug extension path.
  3. Edit config/ Change "php" and "pear" to match the paths in your filesystem (usually /usr/bin/php and /usr/bin/pear).
  4. Run ./composer.phar install

Run the tests

$ bin/

The coverage will be generated as html in runtime/coverage. You can find resulting logs from tests in runtime/log/dev.log

Run the IVR

In your extensions.conf, put these lines (modify to suit your paths):

exten => 123,1,AGI(/home/ivr/bin/
exten => 123,n,Hangup

Run the application by calling 123 (or the extension you've configured). Resulting logs are in runtime/log/production.log