Developed with love by KnpLabs Hire us for your project!
30

RSSClientBundle

by desarrolla2

Service for provide RSS client in your website.

RSSClientBundle

knpbundles.com

Latest Stable Version Total Downloads Build Status

Service for provide RSS client in your website, you can automatically add content to your site from your favorite information providers.

Bundle Installation

Get the bundle

Add to your /composer.json file :

    "require": {
        ...       
        "desarrolla2/rss-client-bundle": "2.*" 
    },

And make

composer update

Register the bundle

// app/AppKernel.php
<?php

  public function registerBundles()
  {
    return array(
      // ...
      new Desarrolla2\Bundle\RSSClientBundle\RSSClientBundle(),
      );
  }

Using RSS Bundle

Configure providers

You need edit your config.yml and add the rss routes you want to get.

# app/config/config.yml
rss_client:
   cache:
      ttl:     3600 # This is the default
   channels:     
      channel_name1:
         - 'http://www.osukaru.es/feed/'
         - 'http://desarrolla2.com/feed/'

      channel_name2:
         - 'http://feeds.feedburner.com/symfony/blog'
         - 'http://www.symfony.es/feed/'

The cache option is completely optional. If not specified the shown default take effect.

Optionally: configure custom processors

If you want to use custom processors to extract additional information from a feed, also add the "processors" key pointing to services that implement the ProcessorInterface.

rss_client:
   processors: ["my_service_id", "my_other_service_id"]

In your controller

Retrieve the service and fetch the content.

<?php

class NewsController extends Controller
{

    /**
     * Renders latest news
     *
     * @return array
     * @Route("/noticias", name="news_index")
     * @Template()
     */
    public function indexAction()
    {
        $this->client = $this->get('rss_client');

        return array(
            'feeds'   => $this->client->fetch('channel_name1'),
        );
    }

}

In your view

Render the content for your users

{% block content %}
    <section>
        {% for feed in feeds %}            
            <article>
                <header>
                    <a href="{{ feed.link }}" target="_blank">{{ feed.title }}</a>
                    <time>{{ feed.pubDate | date('d/m/Y H:i') }}</time>
                </header>
                <p>{{ feed | raw }}</p>
            </article>      
        {% else %}
            <p>Not news :(</p>
        {% endfor %}    
    </section>
{% endblock %}

Contact

You can contact with me on twitter.

More Info

See RSSClient.

Copyright (c) 2012 Desarrolla2 - http://desarrolla2.com

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
rss_client:
cache:
adapter: Desarrolla2\Cache\Adapter\NotCache
ttl: 3600
processors: []

# RSS Client Channels Configuration
channels:

# Prototype
id: []
  • Merge pull request #10 from hostnet/master
    By desarrolla2, 5 years ago
  • Added information about custom processors to README.md
    By Nico Schoenmaker, 5 years ago
  • Merge pull request #9 from hostnet/feature/custom-processors
    By desarrolla2, 5 years ago
  • Allow to add custom processors by service id
    By Nico Schoenmaker, 6 years ago
  • Merge pull request #7 from evolchek/master
    By desarrolla2, 6 years ago
  • Set channels for cached client
    By evolchek, 6 years ago
  • updated composer.json
    By desarrolla2, 6 years ago
  • updated gitignore
    By desarrolla2, 6 years ago
  • merge from master
    By desarrolla2, 6 years ago
  • Update README.md
    By desarrolla2, 6 years ago
  • update dependencies
    By desarrolla2, 6 years ago
  • update dependencies
    By desarrolla2, 6 years ago
  • Update services.xml
    By desarrolla2, 6 years ago
  • Update composer.json
    By desarrolla2, 6 years ago
  • Update README.md
    By desarrolla2, 6 years ago
  • fix rss-client version to 2.X
    By desarrolla2, 6 years ago
  • Merge pull request #6 from ajbdev/patch-1
    By desarrolla2, 6 years ago
  • Update services.xml
    By ajbdev, 6 years ago
  • fix updated to rss-client v2
    By desarrolla2, 6 years ago
  • Fix¬†problem with dependence desarrolla2/rss-client
    By desarrolla2, 6 years ago
  • update composer.json
    By desarrolla2, 6 years ago
  • update composer.json
    By desarrolla2, 6 years ago
  • update composer
    By desarrolla2, 6 years ago
  • resolve conflict
    By desarrolla2, 6 years ago
  • Allow configuration of a cache
    By , 6 years ago
  • Update Resources/config/services.xml
    By itn3rd77, 6 years ago
  • Update DependencyInjection/RSSClientExtension.php
    By itn3rd77, 6 years ago
  • Update DependencyInjection/Configuration.php
    By itn3rd77, 6 years ago
  • update README
    By desarrolla2, 6 years ago
  • fix rss_client.sanitizer.class dependency
    By desarrolla2, 6 years ago