PHP code example of kkamkou / collection-json.php

1. Go to this page and download the library: Download kkamkou/collection-json.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/ */

    

kkamkou / collection-json.php example snippets


use \CollectionJson\Collection;
use \CollectionJson\Property;

$data = new Property\Data('firstName', 'Duck', 'Full name');
$link = new Property\Link('http://example.com', 'homepage', 'Homepage', 'link', 'Link to the homepage');

$item = new Collection\Item('http://example.com/item');
$item->addData($data)->addLink($link);

$collection = new Collection('http://example.com');
$collection->addItem($item);

echo $collection;

\CollectionJson\Collection($href);

\CollectionJson\Collection\Item($href, array $setWithData = array(), array $setWithLinks = array());
\CollectionJson\Collection\Template(array $setWithData = array());
\CollectionJson\Collection\Error($title = null, $code = null, $message = null);

\CollectionJson\Property\Data($name, $value = null, $prompt = null);
\CollectionJson\Property\Link($href, $rel, $name = null, $render = null, $prompt = null);
\CollectionJson\Property\Query($href, $rel, $name = null, $prompt = null, array $data = array());
CollectionTest.php