Skip to content
Rumen Damyanov edited this page Jul 29, 2025 · 13 revisions

PHP Feed Examples

This directory contains comprehensive examples showing how to use the php-feed package with different frameworks and scenarios.

πŸ“ Available Examples

Framework-Specific Examples

Feature Examples

Complete Applications

πŸš€ Quick Start

For the fastest setup, check out the Basic Feed example, which shows the simplest way to get started:

use Rumenx\Feed\FeedFactory;

$feed = FeedFactory::create();
$feed->setTitle('My Feed');
$feed->setDescription('Latest updates');
$feed->setLink('https://example.com');

$feed->addItem([
    'title' => 'Hello World',
    'author' => 'John Doe', 
    'link' => 'https://example.com/hello',
    'pubdate' => date('c'),
    'description' => 'First post content'
]);

echo $feed->render('rss');

πŸ“š Documentation

πŸ†• What's New in v1.0

All examples have been updated for the new framework-agnostic architecture:

  • βœ… Factory Method: Use FeedFactory::create() instead of service providers
  • βœ… Modern PHP: PHP 8.3+ with strict typing and modern syntax
  • βœ… Framework Agnostic: Works with any framework or plain PHP
  • βœ… Array-based Items: Use addItem([...]) instead of individual parameters
  • βœ… Fluent Interface: Chain methods for cleaner code
  • βœ… Better Type Safety: Full type declarations and PHPStan compliance

πŸ”„ Migrating from v0.x

If you're upgrading from older versions, the main changes are:

// Old way (v0.x)
$feed = App::make("feed");
$feed->title = 'My Feed';
$feed->add($title, $author, $url, $date, $description, $content);

// New way (v1.x) 
$feed = FeedFactory::create();
$feed->setTitle('My Feed');
$feed->addItem([
    'title' => $title,
    'author' => $author, 
    'link' => $url,
    'pubdate' => $date,
    'description' => $description
]);

See individual examples for complete migration patterns.

Clone this wiki locally