PHP code example of diversity_templating / diversity-php

1. Go to this page and download the library: Download diversity_templating/diversity-php 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/ */

    

diversity_templating / diversity-php example snippets


use Diversity\Factory\Api;
use Diversity\Collection;
use SAI\System\Curl;

$curl = new Curl;
$factory = new Api('https://api.diversity.io/', $curl);
$component = $factory->get('test', '1.2.3');

echo $component->render();

$curl = new SAI\System\Curl;
$factory = new Api('https://api.diversity.io/', $curl);
$collection = new Collection;
$collection->add($component = $factory->get('test', '1.2.3'));