rudak / rss-bundle
Modern Symfony RSS Bundle for PHP 8.2+
Installs: 50
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/rudak/rss-bundle
Requires
- php: >=8.2
- doctrine/doctrine-bundle: ^2.11
- symfony/config: ^6.4 || ^7.0
- symfony/dependency-injection: ^6.4 || ^7.0
- symfony/framework-bundle: ^6.4 || ^7.0
- symfony/http-kernel: ^6.4 || ^7.0
- symfony/routing: ^6.4 || ^7.0
- symfony/twig-bundle: ^6.4 || ^7.0
- twig/twig: ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.48
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^10.5
- symfony/phpunit-bridge: ^6.4 || ^7.0
This package is auto-updated.
Last update: 2025-12-09 16:47:08 UTC
README
Modern Symfony RSS Bundle for PHP 8.2+ and Symfony 6.4+/7.0+
This bundle generates RSS feeds dynamically for your Symfony application.
Requirements
- PHP 8.2 or higher
- Symfony 6.4+ or 7.0+
Installation
Install the bundle via Composer:
composer require rudak/rss-bundle
If you're not using Symfony Flex, register the bundle manually in config/bundles.php:
return [ // ... Rudak\RssBundle\RudakRssBundle::class => ['all' => true], ];
Configuration
Configure the bundle in config/packages/rudak_rss.yaml:
rudak_rss: rssparameters: entity: repository: 'App\Entity\Article' methodName: 'findLatestArticles' channel: title: 'My Blog RSS Feed' link: 'https://example.com' description: 'Latest articles from my blog' language: 'en' copyright: 'contact@example.com' webmaster: 'webmaster@example.com' managingEditor: 'editor@example.com' generator: 'Symfony RSS Bundle' ttl: '3600' pubDate: type: 'datetime' lastBuildDate: type: 'datetime' image: type: 'image' url: 'https://example.com/logo.png' title: 'My Blog' link: 'https://example.com' items: route: 'article_show' params: id: 'id' slug: type: 'slug' index: 'title' associations: title: 'title' description: 'description' guid: 'id' pubDate: type: 'datetime' index: 'createdAt'
Usage
Basic Usage
Inject the RSS generator service in your controller:
<?php declare(strict_types=1); namespace App\Controller; use Rudak\RssBundle\Classes\RssGenerator; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\Annotation\Route; class RssController extends AbstractController { public function __construct( private readonly RssGenerator $rssGenerator ) { } #[Route('/rss.xml', name: 'rss_feed', methods: ['GET'])] public function feed(): Response { // Option 1: Let the generator fetch entities automatically $this->rssGenerator->makeTheRssContent(); // Option 2: Or provide your own entities // $articles = $this->getDoctrine() // ->getRepository(Article::class) // ->findLatest(15); // $this->rssGenerator->setRssEntities($articles); // $this->rssGenerator->makeTheRssContent(); // Write RSS file $this->rssGenerator->writeTheRssFile(); return new Response('RSS feed generated successfully'); } }
Entity Requirements
Your entities should have getter methods matching the configuration:
<?php declare(strict_types=1); namespace App\Entity; use Doctrine\ORM\Mapping as ORM; #[ORM\Entity] class Article { #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(length: 255)] private ?string $title = null; #[ORM\Column(type: 'text')] private ?string $description = null; #[ORM\Column(type: 'datetime')] private ?\DateTimeInterface $createdAt = null; public function getId(): ?int { return $this->id; } public function getTitle(): ?string { return $this->title; } public function getDescription(): ?string { return $this->description; } public function getCreatedAt(): ?\DateTimeInterface { return $this->createdAt; } }
Development
Installing Dependencies
composer install
Running Tests
composer test
Code Style
Check coding standards:
composer cs-check
Fix coding standards:
composer cs-fix
Static Analysis
Run PHPStan:
composer stan
Features
- ✅ Modern PHP 8.2+ with typed properties and constructor property promotion
- ✅ Compatible with Symfony 6.4+ and 7.0+
- ✅ PSR-12 coding standards
- ✅ Full type hints and strict types
- ✅ Automated testing with PHPUnit 10+
- ✅ Static analysis with PHPStan (level 6)
- ✅ GitHub Actions CI workflow
- ✅ Automatic slug generation for URLs
- ✅ Configurable RSS channel and item mapping
Upgrading from Version 1.x
This version introduces several breaking changes to modernize the codebase:
- PHP Requirement: Now requires PHP 8.2+
- Symfony Requirement: Now requires Symfony 6.4+ or 7.0+
- Namespace Changes: Files moved from root to
src/directory (PSR-4 autoloading) - Service Configuration: Changed from YAML to PHP-based configuration
- Type Safety: All methods now use strict typing and return type declarations
- Service Access: The template namespace changed from
RudakRssBundleto@RudakRss
Migration Steps
- Update your
composer.jsonto require the new version - Run
composer update rudak/rss-bundle - Update your service configuration to use the new parameters format
- Ensure your entities have proper getter methods with return type declarations
- Test your RSS feed generation
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This bundle is released under the GPL-3.0-or-later license. See the LICENSE file for details.
Credits
- Original Author: Kadur Arnaud
- Modernized for PHP 8.2+ and Symfony 6.4+/7.0+