psx/atom
最新稳定版本:v0.2.0
Composer 安装命令:
composer require psx/atom
包简介
Model classes to generate an Atom specification in a type-safe way
README 文档
README
About
This library contains model classes to generate an Atom specification in a type-safe way. The models are
automatically generated based on the TypeSchema specification (s. typeschema.json). The
following example shows how you can generate an Atom spec:
$person = new Person(); $person->setName('foobar'); $person->setUri('http://foo.com'); $person->setEmail('foo@bar.com'); $text = new Text(); $text->setContent('foobar'); $entry = new Entry(); $entry->setAuthor([$person]); $entry->setContent($text); $entry->setId('http://localhost.com#1'); $entry->setTitle('Star City'); $entry->setPublished(LocalDateTime::from(new \DateTime('Tue, 10 Jun 2003 04:00:00 GMT'))); $atom = new Atom(); $atom->setId('http://localhost.com'); $atom->setTitle('Foo has bar'); $atom->setUpdated(LocalDateTime::from(new \DateTime('Tue, 10 Jun 2003 04:00:00 GMT'))); $atom->setEntry([$entry]); echo json_encode($asyncAPI, JSON_PRETTY_PRINT);
This would result in the following JSON:
{
"id": "http:\/\/localhost.com",
"title": "Foo has bar",
"updated": "2003-06-10T04:00:00Z",
"entry": [
{
"author": [
{
"name": "foobar",
"uri": "http:\/\/foo.com",
"email": "foo@bar.com"
}
],
"content": {
"content": "foobar"
},
"id": "http:\/\/localhost.com#1",
"published": "2003-06-10T04:00:00Z",
"title": "Star City"
}
]
}
Contribution
If you want to suggest changes please only change the typeschema.json specification and then run
the php gen.php script to regenerate all model classes.
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2023-04-07