sarsam/ php-atom-writer
简单的Atom写入库
dev-master
2019-05-17 12:46 UTC
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-09-12 00:39:34 UTC
README
\SarSam\AtomWriter
是适用于PHP 5.4或更高版本的简单Atom写入库。此组件受MIT许可证保护。
快速演示
$feed = new Feed(); $feed->title('title') ->subtitle('subtitle') ->link('http://example.org/') ->linkSelf('http://example.org/feed/') ->id('urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6') ->updated(); //updated_at //entry $entry = new Entry(); $entry ->title('title') ->link('http://example.org/2003/12/13/atom03') ->linkAlternate('http://example.org/2003/12/13/atom03.html') ->linkEdit('http://example.org/2003/12/13/atom03/edit') ->id('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a') ->updated(111) ->summary('Some text.') ->content('content') ->author([ 'name' => 'author name', 'email' => 'author email', ]) ->appendTo($feed); echo $feed; // or echo $feed->render();
输出结果
<?xml version="1.0" encoding="UTF-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> <title>title</title> <subtitle>subtitle</subtitle> <link href="http://example.org/" /> <link href="http://example.org/feed/" rel="self" /> <id>urn:uuid:60a76c80-d399-11d9-b91C-0003939e0af6</id> <updated>2003-12-13T18:30:02Z</updated> <entry> <title>13 Cannabis Events to Join in 2018</title> <link href="http://example.org/2003/12/13/atom03" /> <link rel="alternate" type="text/html" href="http://example.org/2003/12/13/atom03.html"/> <link rel="edit" href="http://example.org/2003/12/13/atom03/edit"/> <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id> <summary>Some text.</summary> <updated>2003-12-13T18:30:02Z</updated> <content> <div xmlns="http://www.w3.org/1999/xhtml"> content </div> </content> <author> <name>author name</name> <email>author email</email> </author> </entry> </feed>
安装
简单安装
您可以直接通过Composer进行安装
$ composer require sarsam/atom-feed-writer
手动安装
将以下代码添加到您的 composer.json
文件中
{ "require": { "sarsam/php-atom-writer": "dev-master" } }
...然后运行Composer进行安装
$ composer install
最后,在您的产品中包含 vendor/autoload.php
require_once 'vendor/autoload.php';