Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mekras/atom
Atom Syndication Format support library
https://github.com/mekras/atom
atom
Last synced: 6 days ago
JSON representation
Atom Syndication Format support library
- Host: GitHub
- URL: https://github.com/mekras/atom
- Owner: mekras
- License: mit
- Created: 2016-07-01T10:22:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-17T14:21:18.000Z (over 8 years ago)
- Last Synced: 2024-11-16T04:54:48.936Z (about 1 month ago)
- Topics: atom
- Language: PHP
- Homepage:
- Size: 119 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# [Atom Syndication Format](https://tools.ietf.org/html/rfc4287) support library
[![Latest Stable Version](https://poser.pugx.org/mekras/atom/v/stable.png)](https://packagist.org/packages/mekras/atom)
[![License](https://poser.pugx.org/mekras/atom/license.png)](https://packagist.org/packages/mekras/atom)
[![Build Status](https://travis-ci.org/mekras/atom.svg?branch=master)](https://travis-ci.org/mekras/atom)
[![Coverage Status](https://coveralls.io/repos/mekras/atom/badge.svg?branch=master&service=github)](https://coveralls.io/github/mekras/atom?branch=master)## Purpose
This library is designed to work with the [Atom](https://tools.ietf.org/html/rfc4287) documents in
an object-oriented style. It does not contain the functionality to download or display documents.## Documentation
- [Parsing documents](docs/02-parsing_documents.md)
- [Creating documents](docs/03-creating_documents.md)
- [Extending (custom elements)](docs/06-extending.md)
- [Atom reader example](docs/example.php)## Example
```php
use Mekras\Atom\Document\FeedDocument;
use Mekras\Atom\DocumentFactory;
use Mekras\Atom\Exception\AtomException;$xml = file_get_contents('http://example.com/atom');
$factory = new DocumentFactory();
try {
$document = $factory->parseXML($xml);
} catch (AtomException $e) {
die($e->getMessage());
}if ($document instanceof FeedDocument) {
$feed = $document->getFeed();
echo 'Feed: ', $feed->getTitle(), PHP_EOL;
echo 'Updated: ', $feed->getUpdated()->format('d.m.Y H:i:s'), PHP_EOL;
foreach ($feed->getAuthors() as $author) {
echo 'Author: ', $author->getName(), PHP_EOL;
}
foreach ($feed->getEntries() as $entry) {
echo PHP_EOL;
echo ' Entry: ', $entry->getTitle(), PHP_EOL;
if ($entry->getSelfLink()) {
echo ' URL: ', $entry->getSelfLink(), PHP_EOL;
} else {
echo PHP_EOL, (string) $entry->getContent(), PHP_EOL;
}
}
}
```