sylvrs/libmarshal
最新稳定版本:1.4.3
Composer 安装命令:
composer require sylvrs/libmarshal
包简介
A library used for marshalling/unmarshalling data into objects
README 文档
README
A small marshalling library used to encode/decode data from classes.
Installation
Composer
To install this library through composer, run the following command:
composer require sylvrs/libmarshal
Virion
The virion for this library can be accessed here.
Basic Example
Here is a basic example on how this library is used:
class User { use MarshalTrait; public function __construct( #[Field(name: "first-name")] public string $firstName, #[Field(name: "last-name")] public string $lastName, public int $age, public string $email, #[Exclude] public string $internalData = "..." ) {} } // NOTE: This uses promoted properties to make it easier to construct. // You can learn more about this below. // Marshalling $user = new User(firstName: "John", lastName: "Doe", age: 30, email: "johndoe@gmail.com"); $data = $user->marshal(); // ["first-name" => "John", "last-name" => "Doe", "age" => 30, "email" => "johndoe@gmail.com"] $data["first-name"] = "Jane"; // Changing the first name $data["email"] = "janedoe@gmail.com"; // Changing the email // Unmarshalling $user = User::unmarshal($data); // User(firstName: "Jane", lastName: "Doe", age: 30, email: "janedoe@gmail.com")
Wiki
To learn about how to use the library, please consult the wiki here.
Roadmap
At the moment, there are a few improvements that can be/or are being worked on. Here is a list of some of those improvements:
- Add a limit to recursive objects when marshalling/unmarshalling (50?)
- Cache properties for performance benefits
Issues
Any issues/suggestions can be reported here.
统计信息
- 总下载量: 1.14k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 16
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: gpl-3.0
- 更新时间: 2022-04-23