PHP code example of gideonazure / class_serializer
1. Go to this page and download the library: Download gideonazure/class_serializer 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/ */
gideonazure / class_serializer example snippets
// e Serialize\SerializeJson;
use Serialize\SerializeYaml;
use Serialize\SerializeXml;
// create instance of a class
// with specifying the format of the final data as a class property
// for JSON output data
$JSON = new SerializeJson();
// for YAML output data
$YAML = new SerializeYaml();
// for XML output data
$XML = new SerializeXml();
// and then call "serialize" method of instance
// with passing data object
// return class object in JSON format
$JSON->serilalize(/* class object */);
// return class object in YAML format
$YAML->serilalize(/* class object */);
// return class object in XML format
$XML->serilalize(/* class object */);
// if need catch errors and return message use try->catch construction:
try {
$JSON->serilalize(/* class object */);
} catch (\Exception $e){
echo $e->getMessage();
}
bash
php SerializeTester.php