PHP code example of manoj / toon-php-lite

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

    

manoj / toon-php-lite example snippets


  (new EncodeOptions())->setMinify(true);
  



oonLite\Toon;

$data = [
    'id'    => 1,
    'name'  => 'Manoj',
    'tags'  => ['php', 'ai', 'iot'],
    'items' => [
        ['sku' => 'A1', 'qty' => 2, 'price' => 9.99],
        ['sku' => 'B2', 'qty' => 1, 'price' => 14.5],
    ],
];

$toon = Toon::encode($data);
echo $toon;

$decoded = Toon::decode($toon);
var_dump($decoded);

['id' => 1, 'name' => 'Manoj']

['php', 'ai', 'iot']

['php', 'ai']

[
    ['sku'=>'A1', 'qty'=>2, 'price'=>9.99],
    ['sku'=>'B2', 'qty'=>1, 'price'=>14.5],
]

"Hello\nWorld"

$opts = (new EncodeOptions())->setMinify(true);
echo Toon::encode($data, $opts);
toon
    tags[2]:
      - php
      - ai
    
toon
  bio: """
  I am Manoj.
  I love PHP.
  """
  
bash
composer 
bash
git clone [email protected]:manojrammurthy/toon-php-lite.git
cd toon-php-lite
composer install
toon
tags[3]: php,ai,iot
toon
tags[2]:
  - php
  - ai
bash
composer phpcs
composer php-cs-fixer