marcw/rss-writer

A simple yet powerful RSS2 feed writer with RSS extensions support (like iTunes podcast tags)

0.4.0 2017-04-01 11:53 UTC

This package is not auto-updated.

Last update: 2021-11-26 09:32:15 UTC


README

Build Status SensioLabsInsight Coverage Status

A simple, yet powerful and fully customizable RSS 2.0 writing library, with a native support of iTunes podcasting tags and other RSS extensions.

Why a new Rss writing library?

At the time of writing this library, the current state of feed writing libraries was not satisfying. What I found was either difficult to extend, too generic, or wasn't taking advantage of best practices in order to reduce the Time To First Byte.

Why should I use this over other libraries?

Use this library if you want:

  • RSS2 feeds (because there's no support for other types of feed).
  • Extensions for iTunes podcasting, Slash, Sy, DublinCreator, Atom, or just your own.
  • Best performance (memory and TTFB) thanks to XML Streaming.
  • Object oriented feed creation with POPO

How can I install it?

Run composer require marcw/rss-writer.

How does it work?

Feed creation

See this file.

Rss Streamed Response

See this file.

Symfony Bridge

HttpFoundation

The library provides an extension to the Symfony\Component\HttpFoundation\Response class for streaming rss responses to the client. See RssStreamedResponse.php. Use it from your controllers like this:

use MarcW\RssWriter\Bridge\Symfony\HttpFoundation\RssStreamedResponse;

public function myAction()
{
    // $channel = ... (whatever you use to create your Channel object)

    return new RssStreamedResponse($channel, $this->get('marcw_rss_writer.rss_writer'));
}

Form

An iTunes category choice list is available to use in your forms. Follow this example:

<?php

namespace AppBundle\Form;

use MarcW\RssWriter\Bridge\Symfony\Form\ChoiceList\Loader\ItunesCategoryChoiceLoader;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\FormBuilderInterface;

class MyFormType extends AbstractType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        // ...
        $builder->add('category', ChoiceType::class, ['choice_loader' => new ItunesCategoryChoiceLoader()])
        // ...
    }
}

Symfony Bundle

This library also provides a Symfony bundle.

Add this to your AppKernel.php file.

new MarcW\RssWriter\Bundle\MarcWRssWriterBundle()

You can now use the marcw_rss_writer.rss_writer service.

Can I contribute?

Sure! Feel free to report issues, send pull-requests, or ask for help.

Projects using this lib

  • Banditore retrieves new releases from your Github starred repositories and put them in a RSS feed.

LICENSE

See the LICENSE file.