PHPackages                             kiwilan/php-rss - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. kiwilan/php-rss

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

kiwilan/php-rss
===============

PHP package to generate RSS feeds with presets.

0.3.11(2y ago)01.6k↓50%[2 PRs](https://github.com/kiwilan/php-rss/pulls)MITPHPPHP ^8.1

Since Jun 18Pushed 1y ago1 watchersCompare

[ Source](https://github.com/kiwilan/php-rss)[ Packagist](https://packagist.org/packages/kiwilan/php-rss)[ Docs](https://github.com/kiwilan/php-rss)[ GitHub Sponsors](https://github.com/kiwilan)[ RSS](/packages/kiwilan-php-rss/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (9)Dependencies (7)Versions (12)Used By (0)

PHP RSS
=======

[](#php-rss)

[![Banner with abstract data picture in background and PHP RSS title](https://raw.githubusercontent.com/kiwilan/php-rss/main/docs/banner.jpg)](https://raw.githubusercontent.com/kiwilan/php-rss/main/docs/banner.jpg)

[![php](https://camo.githubusercontent.com/2d44ab343cf5a2aab849b6954ee31dd09ba1f1f11bf0f168ccd08e186ec060b1/68747470733a2f2f696d672e736869656c64732e696f2f7374617469632f76313f7374796c653d666c6174266c6162656c3d504850266d6573736167653d76382e3126636f6c6f723d373737424234266c6f676f3d706870266c6f676f436f6c6f723d666666666666266c6162656c436f6c6f723d313831383162)](https://www.php.net/)[![version](https://camo.githubusercontent.com/1b5185072c7eceb7bc1dd49e67ce9ed9e248d4f6976a81754d5930a0693b4414/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b6977696c616e2f7068702d7273732e7376673f7374796c653d666c617426636f6c6f72413d31383138314226636f6c6f72423d373737424234)](https://packagist.org/packages/kiwilan/php-rss)[![downloads](https://camo.githubusercontent.com/b60ae3cdd68449e14196f0148c5089053965c6a736a79973f4cccba7ecd706ef/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b6977696c616e2f7068702d7273732e7376673f7374796c653d666c617426636f6c6f72413d31383138314226636f6c6f72423d373737424234)](https://packagist.org/packages/kiwilan/php-rss)[![license](https://camo.githubusercontent.com/9556e1af263c1bb027438935f352f86454c290c43b47c42d83b168f4d49ae7ca/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b6977696c616e2f7068702d7273732e7376673f7374796c653d666c617426636f6c6f72413d31383138314226636f6c6f72423d373737424234)](https://github.com/kiwilan/php-rss/blob/main/README.md)[![tests](https://camo.githubusercontent.com/991d823d3f0f62a527e095d817cb958aaf5777c3c61fe879dbaee7a7234a0f35/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6b6977696c616e2f7068702d7273732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c617426636f6c6f72413d313831383142)](https://packagist.org/packages/kiwilan/php-rss)[![codecov](https://camo.githubusercontent.com/f2f6488709eeec89053ea809a1eb940656b59addf451c522dc94a8697b3115b8/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f6b6977696c616e2f7068702d7273732f6d61696e3f7374796c653d666c617426636f6c6f72413d31383138314226636f6c6f72423d373737424234)](https://codecov.io/gh/kiwilan/php-rss)

> **Warning**
>
> NOT READY FOR PRODUCTION

PHP package to generate RSS feeds with presets.

TypeSupportedWithPodcast✅`itunes`, `googleplay`Raw✅Features
--------

[](#features)

// TODO

### Roadmap

[](#roadmap)

- Add JSON feed from  and
- Add blog feed
- Add atom option

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require kiwilan/php-rss
```

Usage
-----

[](#usage)

### Podcast

[](#podcast)

Podcast RSS feed is quite old and has a lot of different versions.

- [Podcast namespace](https://podcastnamespace.org/)
- [Apple Podcasts](https://help.apple.com/itc/podcasts_connect/#/itcb54353390)
- [Google Podcasts](https://support.google.com/podcast-publishers/answer/9889544?hl=en)
- [podcast-standard](https://podcast-standard.org/podcast_standard/)

```
$podcast = Feed::make()->podcast()
  ->title('2 Heures De Perdues')
  ->link('https://www.2hdp.fr')
  ->atomLink('https://www.2hdp.fr/xml')
  ->subtitle('Pourquoi gagner du temps quand on peut en perdre devant de mauvais films ?')
  ->description('Petit podcast de rigolos pour les amateurs de cinéma. Pourquoi gagner du temps quand on peut en perdre devant de mauvais films')
  ->language('fr')
  ->copyright('℗ & © 2019 Fréquence Moderne')
  ->lastUpdate(new DateTime('2021-09-01 00:00:00'))
  ->webmaster('feeds@ausha.co (Ausha)')
  ->generator('Ausha (https://www.ausha.co)')
  ->keywords(['films', 'critiques', 'comédie'])
  ->author('2HDP')
  ->ownerName('2 Heures De Perdues')
  ->ownerEmail('2heuresdeperdues@gmail.com')
  ->isExplicit()
  ->isPrivate()
  ->type(ItunesTypeEnum::episodic)
  ->addCategory(ItunesCategoryEnum::tv_film, ItunesSubCategoryEnum::tv_films_film_reviews)
  ->image('https://raw.githubusercontent.com/kiwilan/php-rss/main/tests/examples/folder.jpeg');

$item1 = PodcastItem::make()
  ->title("Peau d'Ane")
  ->guid('custom-and-unique-key', isPermaLink: true)
  ->subtitle('On discute du chef d\'oeuvre de Jacques. Des réactions ? @2_HDP')
  ->description('On discute du chef d\'oeuvre de Jacques. Des réactions ? @2_HDP')
  ->publishDate('2023-06-14 08:39:25')
  ->enclosure(
      url: 'https://chtbl.com/track/47E579/https://audio.ausha.co/B4mpWfDq5KDa.mp3?t=1685693288',
      length: 56898528,
      type: 'audio/mpeg'
  )
  ->link('https://podcast.ausha.co/2-heures-de-perdues/peau-d-ane')
  ->author('2 Heures de Perdues')
  ->keywords([])
  ->duration(3551)
  ->episodeType(ItunesEpisodeTypeEnum::full)
  ->season(9)
  ->episode(34)
  ->image('https://image.ausha.co/XboDHYC69Oorw8MBObAkQ2sTPdxGTkexH3nYQ8Ky_1400x1400.jpeg?t=1619074925');

$podcast->addItem($item1); // Add item to podcast
$podcast->get(); // Get XML feed
```

### Raw

[](#raw)

> *Note*
>
> You can use [`spatie/array-to-xml`](https://github.com/spatie/array-to-xml#using-custom-keys) usage guide to help you.

```
$podcast = Feed::make()
        ->template(
            root: 'rss',
            version: '1.0',
            encoding: 'UTF-8',
            attributes: [
                ...FeedConstants::RSS_FEED,
                'xmlns:itunes' => 'http://www.itunes.com/dtds/podcast-1.0.dtd',
            ],
        )
        ->raw()
        ->channel([
            'title' => '2 Heures De Perdues',
            'link' => 'https://www.2hdp.fr',
            'description' => 'Petit podcast de rigolos pour les amateurs de cinéma. Pourquoi gagner du temps quand on peut en perdre devant de mauvais films',
            'language' => 'fr',
            'lastBuildDate' => 'Wed, 01 Sep 2021 00:00:00 +0000',
        ])
        ->addItem([
            'title' => "Peau d'Ane",
            'link' => 'https://podcast.ausha.co/2-heures-de-perdues/peau-d-ane',
            'description' => 'On discute du chef d\'oeuvre de Jacques. Des réactions ? @2_HDP',
            'pubDate' => 'Wed, 14 Jun 2023 08:39:25 +0000',
            'enclosure' => [
                '_attributes' => [
                    'url' => 'https://chtbl.com/track/47E579/https://audio.ausha.co/B4mpWfDq5KDa.mp3?t=1685693288',
                    'length' => '56898528',
                    'type' => 'audio/mpeg',
                ],
            ],
            '__custom:itunes\\:author' => '2 Heures de Perdues',
            '__custom:itunes\\:duration' => '00:59:11',
            '__custom:itunes\\:episodeType' => 'full',
        ]);
```

### Example with Laravel

[](#example-with-laravel)

```
