PHP code example of nir-simionovich / cloudonix-php8

1. Go to this page and download the library: Download nir-simionovich/cloudonix-php8 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/ */

    

nir-simionovich / cloudonix-php8 example snippets




loudonix\CXML\CXML;
use Cloudonix\CXML\Verbs\Gather\Gather;
use Cloudonix\CXML\Verbs\Record\Record;

// Create a simple CXML document
$response = CXML::response();
$response->addChild(CXML::say('Hello, world!'));
$response->addChild(CXML::hangup());

// Output the CXML document
header('Content-Type: text/xml');
echo $response->toDocument();



loudonix\CXML\CXML;
use Cloudonix\CXML\Verbs\Gather\Gather;
use Cloudonix\CXML\Verbs\Record\Record;

// Create a more complex CXML document
$response = CXML::response();

// Add a welcome message
$response->addChild(
    CXML::say('Welcome to our system.')
        ->voice('woman')
        ->language('en-US')
);

// Create a gather with nested elements
$gather = CXML::gather()
    ->input('dtmf speech')
    ->timeout(5)
    ->action('https://example.com/handle-input');

// Add nested elements to the gather using children() with a closure
$gather->children(function($cxml) {
    $cxml->say('Please enter your account number followed by the pound key.')
        ->pause(1);
});

// Add the gather to the response
$response->addChild($gather);

// Add a fallback
$response->addChild(CXML::say('We did not receive any input. Goodbye.'));
$response->addChild(CXML::hangup());

// Output the CXML document
header('Content-Type: text/xml');
echo $response->toDocument();



loudonix\CXML\CXML;
use Cloudonix\CXML\Verbs\Gather\Gather;
use Cloudonix\CXML\Verbs\Record\Record;

// Create a record verb with nested elements
$record = CXML::record()
    ->action('https://example.com/handle-recording')
    ->playBeep(true)
    ->maxLength(60);

// Add nested elements using the children() method with a closure
$record->children(function($cxml) {
    $cxml->say('Please record your message after the beep.')
        ->pause(1)
        ->play('https://example.com/beep.mp3');
});

// Add the record to the response
$response->addChild($record);