Search by

mekras / atom

Mekras

Atom Protocol support library

Package info

github.com/mekras/atom

pkg:composer/mekras/atom

Statistics

Installs: 11 424

Dependents: 1

Suggesters: 0

Stars: 1

Open Issues: 1

v1.0.0 2016-08-17 14:20 UTC

This package is auto-updated.

Last update: 2026-11-13 17:57:13 UTC


README

Maintenance status

This project is no longer maintained and is archived for historical reference. No further updates or fixes, including security fixes, are planned. Compatibility with current PHP versions and dependencies has not been verified. The documentation and examples below describe the historical version.

Latest Stable Version License Build Status Coverage Status

Purpose

This library is designed to work with the Atom documents in an object-oriented style. It does not contain the functionality to download or display documents.

Documentation

Example

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;
        }
    }
}