Giter Club home page Giter Club logo

phparess's Introduction

README

phparess is a set of PHP classes for generating RSS content, based on the 2.0 spec. It consists of three public classes that are used to define feed data:

  • Feed represents a complete RSS feed
  • Channel represents the channel of an RSS feed
  • Item represents an individual item in the channel

Both the channel and individual item can be created with their constructor, passing in an array of spec-defined properties to assign.

Channels

For example, I can create a new channel by saying:

$channel = new Channel(array(
	"title"=>"tylerchr's projects",
	"link"=>"http://github.com/tylerchr",
	"description"=>"tylerchr writes code on github"
));

We can define additional properties, such as language, copyright, and lastBuildDate the same way.

Items

Items are created identically to channels, by using the constructor:

$item = new Item(array(
	"title"=>"phparess (tylerchr project)",
	"link"=>"http://github.com/tylerchr/phparess",
	"description"=>"phparess is for generating simple RSS content"
));

Again, additional item properties can be added into the array, given that they are part of the RSS 2.0 spec. Non-specced properties will not be added.

We add items to our channel by saying $channel->addItem($item) and if we want to add many items at once, we can say $channel->addItems($items) passing in an array of Item objects.

The final feed

When we want to get the complete feed, we create a Feed object, set the channel, and then we can echo it back out. This is trivial, and to be true to spec, we should add a MIME type declaration at the top:

header('Content-type: application/rss+xml');	
$rss = new Feed();
$rss->setChannel($channel);
echo $rss;

Feedback

Feedback is welcome, but keep in mind that this is a work in progress.

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.