Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Zend Feed Laravel Package

zendframework/zend-feed

Abandoned Zend Framework package for consuming and generating RSS and Atom feeds, with a natural API for reading/modifying feed and entry elements and rendering back to XML. Moved to laminas/laminas-feed.

View on GitHub
Deep Wiki
Context7

Introduction

Zend\Feed provides functionality for consuming RSS and Atom feeds. It provides a natural syntax for accessing elements of feeds, feed attributes, and entry attributes. Zend\Feed also has extensive support for modifying feed and entry structure with the same natural syntax, and turning the result back into XML. In the future, this modification support could provide support for the Atom Publishing Protocol.

Zend\Feed consists of Zend\Feed\Reader for reading RSS and Atom feeds, Zend\Feed\Writer for writing RSS and Atom feeds, and Zend\Feed\PubSubHubbub for working with Hub servers. Furthermore, both Zend\Feed\Reader and Zend\Feed\Writer support extensions which allows for working with additional data in feeds, not covered in the core API but used in conjunction with RSS and Atom feeds.

In the example below, we demonstrate a simple use case of retrieving an RSS feed and saving relevant portions of the feed data to a simple PHP array, which could then be used for printing the data, storing to a database, etc.

RSS optional properties

Many RSS feeds have different channel and item properties available. The RSS specification provides for many optional properties, so be aware of this when writing code to work with RSS data. Zend\Feed supports all optional properties of the core RSS and Atom specifications.

Reading RSS Feed Data

// Fetch the latest Slashdot headlines
try {
    $slashdotRss =
        Zend\Feed\Reader\Reader::import('http://rss.slashdot.org/Slashdot/slashdot');
} catch (Zend\Feed\Reader\Exception\RuntimeException $e) {
    // feed import failed
    echo "Exception caught importing feed: {$e->getMessage()}\n";
    exit;
}

// Initialize the channel/feed data array
$channel = [
    'title'       => $slashdotRss->getTitle(),
    'link'        => $slashdotRss->getLink(),
    'description' => $slashdotRss->getDescription(),
    'items'       => [],
];

// Loop over each channel item/entry and store relevant data for each
foreach ($slashdotRss as $item) {
    $channel['items'][] = [
        'title'       => $item->getTitle(),
        'link'        => $item->getLink(),
        'description' => $item->getDescription(),
    ];
}

Your $channel array now contains the basic meta-information for the RSS channel and all items that it contained. The process is identical for Atom feeds since Zend\Feed provides a common feed API; i.e. all getters and setters are the same regardless of feed format.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport