laminas/laminas-feed
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
laminas/laminas-escaper | 2.13.0 | 8.94 kB | BSD-3-Clause | prod | |
laminas/laminas-stdlib | 3.19.0 | 49.04 kB | BSD-3-Clause | prod |
The laminas/laminas-feed is a resourceful PHP library that provides functionality for creating and consuming RSS and Atom feeds. It allows users to easily access elements of feeds including feed attributes, and entry attributes. The library also offers extensive support for modifying feed and entry structure using a natural syntax, which can then be transformed back into XML.
To use laminas/laminas-feed, you would need to install it first using Composer, the commonly used dependency manager in PHP. This can be done with the following command composer require laminas/laminas-feed
.
Once installed, you can start using the library to read feeds. Here's a simple example of how you might utilize the functionality to read an RSS feed:
use Laminas\Feed\Reader\Reader;
$feed = Reader::import('https://example.com/rss-feed');
foreach ($feed as $entry) {
echo $entry->getTitle() . "\n";
echo $entry->getDescription() . "\n";
}
In the above code, an RSS feed from 'https://example.com/rss-feed' is being read, and the title and description of each entry in the feed is being printed out.
Similarly, here is how you might use this library to write a feed:
use Laminas\Feed\Writer\Feed;
$feed = new Feed;
$feed->setTitle('Feed Title');
$feed->setDescription('Feed Description');
$feed->setLink('https://example.com');
$entry = $feed->createEntry();
$entry->setTitle('Entry Title');
$entry->setDescription('Entry Description');
$entry->setLink('https://example.com/entry');
$feed->addEntry($entry);
echo $feed->export('rss');
In this code, a new feed is created with a title, a description, and a link. An entry is then created for the feed, also with a title, a description, and a link, which is then added to the feed. The feed is finally printed out as an RSS using the export method.
The documentation for the laminas/laminas-feed library can be found at https://docs.laminas.dev/laminas-feed/. This offers a depth of information about the package, including comprehensive instructions for both using and contributing to the library, in addition to answers to frequently asked questions and information about additional resources.