PHP Classes

File: README.md

Recommend this page to a friend!
  Packages of Murilo Gomes Julio   MGTOON   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: MGTOON
Perform operations with values in TOON format
Author: By
Last change: Update description
Date: 3 months ago
Size: 1,602 bytes
 

Contents

Class file image Download

MGTOON

MGTOON é uma biblioteca para trabalhar com Token-Oriented Object Notation no PHP.

Installation

composer require mugomes/mgtoon

Example

use MGTOON\MGTOON;

include_once(__DIR__ . '/vendor/autoload.php');

$toon = new MGTOON();

// Load TOON and primary key "name"
$toon->loadFile(__DIR__ . '/users.toon', 'name');

// Load TOON string and primary key "name"
$toon->loadTOON('user[name|email|active]
Maria|maria@localhost|1
Joćo|joao@localhost|0', 'name');

// Added Fields and primary key "name"
$toon->create('user', ['name', 'email', 'active'], 'name');

// Added Items
$toon->add(['name' => 'Maria', 'email' => 'maria@localhost', 'active' => 1]);
$toon->add(['name' => 'Joćo', 'email' => 'joao@localhost', 'active' => 0]);

// Query
echo "\nQuery\n";
print_r($toon->read());

// Update
echo "\n\nUpdate\n";
$toon->update('Maria', ['active' => 0]);

// Read
echo "\n\nRead\n";
print_r($toon->read('Maria'));

// Delete
echo "\n\nDelete\n";
$toon->delete('Joćo');

// TOON
echo "\nTOON\n";
print_r($toon->toString());

// Validate
echo "\n\nValidate\n";
print_r($toon->validate($toon->toString(), 'name'));

// Save File
$toon->saveFile(__DIR__ . '/users.toon');

Support

  • GitHub Sponsors: https://github.com/sponsors/mugomes/
  • More Options: https://www.mugomes.com.br/apoie.html

License

The MGTOON is provided under:

SPDX-License-Identifier: LGPL-2.1-only

Beign under the terms of the GNU Lesser General Public License version 2.1 only.

All contributions to the MGTOON are subject to this license.