The documentation for the Cloudonix CXML markup language can be found here.
The PHP library documentation can be found here
This library supports the following PHP versions:
- PHP 8.0
- PHP 8.1
- PHP 8.2
- PHP 8.3
You can install cxml-php
via composer or by downloading the source.
composer require cloudonix/cxml-php
Here is a sample PHP script that will generate a CXML Voice Application document, using the library:
<?php
require(__DIR__ . "/vendor/autoload.php");
use Cloudonix\CXML\Response;
$responder = new Response();
$responder->dial("12127773456");
$responder->redirect("https://example.com/script.php");
$responder->gather([
(new Response())->play("https://example.com/playfile.mp3")->attributes(["loop" => 3]),
(new Response())->pause()->attributes(["length" => 5]),
])->attributes(["action" => "https://example.com/script.php"]);
$responder->hangup();
echo $responder;
Copy&Paste the above script to a new file, and execute it from the command line, the following should be the result:
$ php cxmlResponder.php
<Response>
<DIAL>12127773456</DIAL>
<REDIRECT>https://example.com/script.php</REDIRECT>
<GATHER action="https://example.com/script.php">
<PLAY loop="3">https://example.com/playfile.mp3</PLAY>
<PAUSE length="5" />
</GATHER>
<HANGUP />
</Response>
<?php
require(__DIR__ . "/vendor/autoload.php");
use Cloudonix\CXML\Response;
$responder = new Response();
$responder
->play("https://example.com/playfile.mp3")
->attributes([
"loop" => 3,
"statusCallback" => "https://example.com/statusCallback"
]);
$responder->hangup();
echo $responder;
Expected result:
<Response>
<PLAY loop="3" statusCallback="https://example.com/statusCallback">https://example.com/playfile.mp3</PLAY>
<HANGUP />
</Response>
<?php
require(__DIR__ . "/vendor/autoload.php");
use Cloudonix\CXML\Response;
$responder = new Response();
$responder->gather([
(new Response())->play("https://example.com/playfile.mp3")->attributes(["loop" => 3]),
(new Response())->pause()->attributes(["length" => 5]),
])->attributes(["action" => "https://example.com/script.php"]);
$responder->hangup();
echo $responder;
Expected result:
<Response>
<GATHER action="https://example.com/script.php">
<PLAY loop="3">https://example.com/playfile.mp3</PLAY>
<PAUSE length="5" />
</GATHER>
<HANGUP />
</Response>
If you need help installing or using the library, please check the Cloudonix Developers Website first.
If you've instead found a bug in the library or would like new features added, go ahead and open issues or pull requests against this repo!