ddebin / atom-generator
Atom feed generator
Installs: 1 006
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^7.1 || ^8.0
- ext-dom: *
- ext-filter: *
- ext-libxml: *
- ext-simplexml: *
- webmozart/assert: ^1.5
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- phpstan/phpstan: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-strict-rules: ^1.0
- phpstan/phpstan-webmozart-assert: ^1.0
- phpunit/phpunit: ^7.0 || ^8.0 || ^9.0
README
Atom feed generator
This library is an [Atom](https://en.wikipedia.org/wiki/Atom_(Web_standard) feed generator, PHP 7.1+, fully typed (PHPStan level 7, 100% code coverage). Follows W3C standard (RFC 4287).
Installing
Install via Composer:
composer require ddebin/atom-generator
Example
<?php include_once 'vendor/autoload.php'; $entry = new AtomGenerator\Entry(); $entry->setTitle('Post', 'text'); $entry->setId('tag:id'); $entry->setContent('Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.', 'text'); $entry->setUpdatedDateTime(new DateTime('2019-05-04T21:00:40Z')); $feed = new AtomGenerator\Feed(); $feed->setTitle('Blog'); $feed->setUpdatedDateTime(new DateTime('now')); $feed->addEntry($entry); assert(AtomGenerator\Feed::validate($feed->getDocument())); 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).