laminas/laminas-feed
Laminas\Feed provides tools for reading and creating RSS and Atom feeds in PHP. Parse feeds, work with entries and metadata, and generate valid syndication output for your applications or services.
Start by installing laminas/laminas-feed via Composer, then use Laminas\Feed\Reader\Reader::import($url) to fetch and parse RSS or Atom feeds. The method returns either a Feed\RSS or Feed\Atom object (auto-detected), offering a consistent interface: $feed->getTitle(), $feed->getAuthor(), $feed->count(), and iteration over entries via foreach. For entries, access properties like $entry->getTitle(), $entry->getDescription(), and $entry->getLink(). If not using laminas-http, inject an HTTP client into Reader::setHttpClient()—this is critical for import() to function. First use case: pull blog posts or news headlines for aggregation or caching.
Laminas\Cache) to store parsed feeds and reduce HTTP calls. Store the feed XML or deserialized entry objects, with cache TTL based on feed pubDate or max-age hints.Reader\Entry\Rss or Reader\Entry\Atom to add domain-specific getters (e.g., getEnclosureUrl() for podcast feeds), or implement Reader\FeedInterface/Reader\EntryInterface for custom behavior.Reader::import() without type assumptions—both feed types expose consistent methods (getTitle(), getEntries()) even if internally backed by different parsers.podcast-index via Reader::getExtensions()) or register custom namespaces. Use Reader::getReader() to access the underlying reader instance and peek at namespaces via getNamespaces().FeedFetcherJob) with error recovery—wrap import() in try/catch to handle network failures or malformed XML.Reader::import() silently fails if no HTTP client is available—ensure laminas/laminas-http is installed or inject a PSR-18 client explicitly.Reader::registerExtension(). Check availability with Reader::hasExtension('PodcastIndex').getAuthor()) may return arrays (e.g., ['name' => '...', 'email' => '...']) depending on feed structure—always validate return type before accessing keys.DateTime construction to normalize them, e.g., new \DateTime($entry->getDatePublished()).count(), iteration)—avoid redundant calls to $feed->getEntries() inside loops.Exception\RuntimeException; malformed feeds may throw Exception\DomException—log feed URLs alongside exceptions for debugging.getSummary() and getContent(); RSS uses getDescription(). Prefer getContent() or getDescription() conditionally based on feed type.<?xml version="1.0" encoding="UTF-8"?>). This prevents garbled characters in multi-byte fields (e.g., titles/descriptions in non-Latin scripts). Verify output with mb_check_encoding() if handling localized content.How can I help you explore Laravel packages today?