PHP Classes

PHP RSS Generator: Generate a RSS feed with a fluent interface

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
StarStarStar 47%Total: 176 All time: 8,768 This week: 660Up
Version License PHP version Categories
php-rss-generator 1.0.3Custom (specified...5XML, PHP 5
Description 

Author

This package can be used to generate a RSS feed with a fluent interface.

It provides several classes to compose several parts of the RSS feed like the feed, channel and items.

Items can be added to a channel and the channel can be added to a feed.

The composed RSS feed XML can be outputted in RSS 2.0 format.

Picture of Bhaktaraz Bhatta
Name: Bhaktaraz Bhatta <contact>
Classes: 1 package by
Country: Nepal Nepal

Example

<?php

use Bhaktaraz\RSSGenerator\Item;
use
Bhaktaraz\RSSGenerator\Feed;
use
Bhaktaraz\RSSGenerator\Channel;

require
'vendor/autoload.php';

$feed = new Feed();
$channel = new Channel();
$channel
   
->title("Channel Title")
    ->
description("Channel Description")
    ->
url('http://bhaktaraz.com.np')
    ->
language('en-US')
    ->
copyright('Copyright 2015, Bhaktaraz')
    ->
pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
    ->
lastBuildDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
    ->
updateFrequency(1)
    ->
updatePeriod('hourly')
    ->
ttl(60)
    ->
appendTo($feed);

$item = new Item();
$item
   
->title("Item Title")
    ->
creator("Deepak Pandey")
    ->
description("Item body")
    ->
content("<p class=\"popPara\" style=\"text-align: justify;\"><a href=\"http://www.onlinekhabar.com/wp-content/uploads/2015/11/kathmandu_view_tower_Old_buspark.jpg\"><img class=\"aligncenter wp-image-349218\" src=\"http://www.onlinekhabar.com/wp-content/uploads/2015/11/kathmandu_view_tower_Old_buspark.jpg\" alt=\"kathmandu_view_tower_Old_buspark\" width=\"810\" height=\"523\" srcset=\"http://www.onlinekhabar.com/wp-content/uploads/2015/11/kathmandu_view_tower_Old_buspark.jpg 650w, http://www.onlinekhabar.com/wp-content/uploads/2015/11/kathmandu_view_tower_Old_buspark-300x194.jpg 300w\" sizes=\"(max-width: 810px) 100vw, 810px\" /></a>?? ???, ???????? ? ??????? ????????? ?????? ???? ?????? ????????? ????? ??????? ???????? ?????? ??????? ????? ???????? ????? ? ?</p>
<p class=\"popPara\" style=\"text-align: justify;\">???? ????????? ???????? ??????? ??????? ???????????? ?????? ??????? ????? ???? ???? ???? ???? ????????? ?????? ????? ???????, ??????? ? ??????? ?????? ???? ???????? ??????? ??? ? ???? ?????? ???????, ??????, ?????? ????????????? ???????????? ???? ??? ????????? ????? ??????? ???????????? ? ?</p>
<p class=\"popPara\" style=\"text-align: justify;\">??? ?????? ????????? ??????? ?????? ??????? ? ? ??????? ?????? ??????? ???? ????? ???????? ? ??????? ?????? ??????? ??????? ??? ???? ??????? ? ?</p>
<p>?????????? ?????????? ??? ??????? ???? ??? ?? ??????? ???? ???? ?????? ????????? ??????? ????? ??? ????????? ??????? ???????????? ??????????? ???????? ? ?</p>
<p>????????????? ??? ????????? ??????? ?????? ?????? ??? ?????????? ?????? ????????????? ? ?? ??????? ?????? ????? ? ? ??????? ??????? ????? ???????? ???? ? ?????????????? ?????? ???, ???????? ??????? ????? ???? ??????? ? ?</p>
<p>???????? ????? ????????????? ?? ???????? ????? ??????? ??? ????? ?? ???????? ?????? ??? ? ??? ???? ???? ???? ????????? ?? ???? ?????????????? ? ?</p>
<p>?????? ???? ?? ??? ???? ?? ???? ?????? ?????? ?????? ???????????? ???????? ??????????? ???????? ???????? ??????? ? ????? ???????? ????? ????? ???? ??????? ???? ? ? ???????, ?????? ???? ??? ????? ????? ?????? ???????, ????????? ?????? ??, ???? ?????, ?????????, ???? ??? ?????????????? ??? ???????????? ????? ? ????? ???? ?? ????? ???? ??? ????? ?????????? ? ?</p>"
)
    ->
url('http://bhaktaraz.com.np/?p=2')
    ->
pubDate(strtotime('Mon, 03 Aug 2015 10:22:02 +0550'))
    ->
guid('http://bhaktaraz.com.np/?p=2', true)
    ->
appendTo($channel);


echo
$feed; // or echo $feed->render();


Details

\Bhaktaraz\RSSGenerator

\Bhaktaraz\RSSGenerator is RSS generator library for PHP 5.5 or later.

Scrutinizer Code Quality Build Status

Installation

You can install via Composer.

Add in your composer.json file:

{
	"require": {
		"bhaktaraz/php-rss-generator": "dev-master"
	}
}

Run composer to install.

$ composer update

RSS Feed Implementation:

<?php
$feed = new Feed();

$channel = new Channel();
$channel
	->title("Programming")
	->description("Programming with php")
	->url('http://bhaktaraz.com.np/?cat=2')
	->appendTo($feed);

// RSS item
$item = new Item();
$item
	->title("CACHING DATA IN SYMFONY2")
	->description("It is not too easy to enhance the performance of your application. In Symfony2 you could get benefit from caching.")
	->url('http://bhaktaraz.com.np/?p=194')
	->enclosure('http://bhaktaraz.com.np/wp-content/uploads/2014/08/bhakta-672x372.jpg', 4889, 'audio/mpeg')
	->appendTo($channel);

echo $feed;

Output:

<?xml version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Programming</title>
    <link>http://bhaktaraz.com.np/?cat=2</link>
    <description>Programming with php</description>
    <item>
      <title>CACHING DATA IN SYMFONY2</title>
      <link>http://bhaktaraz.com.np/?p=194</link>
      <description>It is not too easy to enhance the performance of your application. In Symfony2 you could get benefit from caching.</description>
      <enclosure url="http://bhaktaraz.com.np/wp-content/uploads/2014/08/bhakta-672x372.jpg" type="audio/mpeg" length="4889"/>
    </item>
  </channel>
</rss>

Facebook product feed implementation:

<?php
$feed = new Feed();

$channel = new Channel();
$channel
	->title("geekyrepo")
	->description("geekyrepo - for geeks by a geek")
	->url('https://geekyrepo.pasls.com')
	->appendTo($feed);

// Product feed item
$item = new FacebookProductItem();
$item
	->id(78)
	->title("elePHPant Small")
	->description("elePHPant hand made in nepal.")
	->url('https://geekyrepo.pasls.com/product/elephpant-small')
	->availability('in stock') 
	->condition('new') 
	->googleProductCategory('Apparel & Accessories > Clothing > Underwear & Socks')
	->imageLink('https://geekyrepo.pasls.com/u/591415cc603dc_elephant-blue-small.jpg')
	->brand('GeekyRepo')
	->customLabel0('elephpant-small')
	->customLabel1('ELESM')
	->customLabel2('https://geekyrepo.pasls.com/product/elephpant-small')
	->appendTo($channel);

echo $feed;

Output:

<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:g="http://base.google.com/ns/1.0" version="2.0">
<channel xmlns:g="http://base.google.com/ns/1.0">
	<title>geekyrepo</title>
	<link>https://geekyrepo.pasls.com</link>
	<description>geekyrepo</description>

	<item xmlns:g="http://base.google.com/ns/1.0">
		<g:id xmlns:g="http://base.google.com/ns/1.0">78</g:id>
		<g:title xmlns:g="http://base.google.com/ns/1.0">elePHPant Small</g:title>
		<g:link xmlns:g="http://base.google.com/ns/1.0">
		https://geekyrepo.pasls.com/product/elephpant-small
		</g:link>
		<g:description xmlns:g="http://base.google.com/ns/1.0">elePHPant hand made in nepal.</g:description>
		<g:availability xmlns:g="http://base.google.com/ns/1.0">in stock</g:availability>
		<g:price xmlns:g="http://base.google.com/ns/1.0">699 NPR</g:price>
		<g:condition xmlns:g="http://base.google.com/ns/1.0">new</g:condition>
		<g:google_product_category xmlns:g="http://base.google.com/ns/1.0">
		Apparel & Accessories > Clothing > Underwear & Socks
		</g:google_product_category>
		<g:image_link xmlns:g="http://base.google.com/ns/1.0">
		https://geekyrepo.pasls.com/u/591415cc603dc_elephant-blue-small.jpg
		</g:image_link>
		<g:brand xmlns:g="http://base.google.com/ns/1.0">geekyrepo</g:brand>
		<g:custom_label_0 xmlns:g="http://base.google.com/ns/1.0">elephpant-small</g:custom_label_0>
		<g:custom_label_1 xmlns:g="http://base.google.com/ns/1.0">
		https://geekyrepo.pasls.com/product/elephpant-small
		</g:custom_label_1>
		<g:custom_label_2 xmlns:g="http://base.google.com/ns/1.0">ELESM</g:custom_label_2>
	</item>

</channel>
</rss>

  Files folder image Files (17)  
File Role Description
Files folder imageSource (1 directory)
Files folder imageTests (4 files)
Accessible without login Plain text file .travis.yml Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

  Files folder image Files (17)  /  Source  
File Role Description
Files folder imageBhaktaraz (1 directory)

  Files folder image Files (17)  /  Source  /  Bhaktaraz  
File Role Description
Files folder imageRSSGenerator (8 files)

  Files folder image Files (17)  /  Source  /  Bhaktaraz  /  RSSGenerator  
File Role Description
  Plain text file Channel.php Class Class source
  Plain text file ChannelInterface.php Class Class source
  Plain text file FacebookProductItem.php Class Class source
  Plain text file Feed.php Class Class source
  Plain text file FeedInterface.php Class Class source
  Plain text file Item.php Class Class source
  Plain text file ItemInterface.php Class Class source
  Plain text file SimpleXMLElement.php Class Class source

  Files folder image Files (17)  /  Tests  
File Role Description
  Accessible without login Plain text file Bootstrap.php Aux. Auxiliary script
  Accessible without login Plain text file composer.json Data Auxiliary data
  Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
  Accessible without login Plain text file README.md Doc. Documentation

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:176
This week:0
All time:8,768
This week:660Up
 User Ratings  
 
 All time
Utility:58%StarStarStar
Consistency:66%StarStarStarStar
Documentation:58%StarStarStar
Examples:58%StarStarStar
Tests:-
Videos:-
Overall:47%StarStarStar
Rank:3094