Giter Club home page Giter Club logo

rssclientbundle's Introduction

RSSClientBundle

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

build status : Build Status

Bundle Installation

Get the bundle

Add to your /composer.json file :

    "require": {
        ...       
        "desarrolla2/rss-client-bundle": "dev-master" 
    },

And make

composer update

Register the bundle

<?php

  // app/AppKernel.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:
      adapter: Desarrolla2\Cache\Adapter\NotCache # This is the default
      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.

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 %}

Coming soon

  • This client only was tested with RSS2.0 other format not guaranteed.

Contact

You can contact with me on twitter.

rssclientbundle's People

Contributors

desarrolla2 avatar itn3rd77 avatar ajbdev avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.