gideonazure/class_serializer
Composer 安装命令:
composer require gideonazure/class_serializer
包简介
This is a project for class serialization
README 文档
README
This project based on a default structure for PHP projects and help to serialize any class into JSON, YAML or XML formats.
Installation
Use the composer package to install class serializer.
composer require gideonazure/class_serializer
Usage
// require needed class to your project use 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(); }
Demo
For demo use and check the functionality - run the file "SerializeTester.php" from the "/tests" folder
php SerializeTester.php
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
License
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-08-16