项目作者: ddebin

项目描述 :
A very simple Atom feed generator library
高级语言: PHP
项目地址: git://github.com/ddebin/atom-generator.git
创建时间: 2019-09-13T07:45:04Z
项目社区:https://github.com/ddebin/atom-generator

开源协议:MIT License

下载


CI
Codecov
PHP from Packagist
Packagist Version
Packagist

Atom feed generator

This library is an Atom feed generator, PHP 7.1+, fully typed (PHPStan level 7, 100% code coverage). Follows W3C standard
(RFC 4287).

Installing

Install via Composer:

  1. composer require ddebin/atom-generator

Example

  1. <?php
  2. include_once 'vendor/autoload.php';
  3. $entry = new AtomGenerator\Entry();
  4. $entry->setTitle('Post', 'text');
  5. $entry->setId('tag:id');
  6. $entry->setContent('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'text');
  7. $entry->setUpdatedDateTime(new DateTime('2019-05-04T21:00:40Z'));
  8. $feed = new AtomGenerator\Feed();
  9. $feed->setTitle('Blog');
  10. $feed->setUpdatedDateTime(new DateTime('now'));
  11. $feed->addEntry($entry);
  12. assert(AtomGenerator\Feed::validate($feed->getDocument()));
  13. echo $feed->saveXML();

Validation

A validation tool is included with static method Feed::validate. It uses a Relax NG schema coming from https://validator.w3.org/feed/docs/rfc4287.html#schema (inspired by https://cweiske.de/tagebuch/atom-validation.htm).