PHPackages                             innoscience/comrade-opml - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. innoscience/comrade-opml

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

innoscience/comrade-opml
========================

Comrade need help with OPML, da? We read and write OPML data together no problem. It to spec &amp; simple too, with PHP.

1.0.0(12y ago)1100↓80%1GPLv2PHPPHP &gt;=5.3.0

Since Mar 25Pushed 12y ago1 watchersCompare

[ Source](https://github.com/innoscience/comrade-opml)[ Packagist](https://packagist.org/packages/innoscience/comrade-opml)[ Docs](https://github.com/innoscience/comrade-opml)[ RSS](/packages/innoscience-comrade-opml/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

ComradeOPML
===========

[](#comradeopml)

Comrade need help with OPML, da? We read and write OPML data together no problem. It to spec &amp; simple too, with PHP.

[![Build Status](https://camo.githubusercontent.com/2402e625bacf656eb909dcf860e31fe70ff71ec555bdd2552efea679c2db8389/68747470733a2f2f7472617669732d63692e6f72672f696e6e6f736369656e63652f636f6d726164652d6f706d6c2e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/innoscience/comrade-opml)

Copyright (C) 2014 Brandon Fenning

Requirements
------------

[](#requirements)

Compatible with PHP 5.3+

Installation
------------

[](#installation)

Add `innoscience/comrade-opml` to the `composer.json` file:

```
"require": {
    "innoscience/comrade-opml": "dev-master"
}

```

After this, run `composer update`

ComradeOPML is namespaced to `Innoscience\ComradeOPML`, use this in the top of any files that require it:

```
use Innoscience\ComradeOPML\ComradeOPML;

```

Usage
-----

[](#usage)

### Importing &amp; Reading an OPML File

[](#importing--reading-an-opml-file)

```
$document = ComradeOPML::importFile('file.opml');

foreach ($document->getAllCategories() as $category) {

	echo ''.$category->getText().'';

	foreach ($category->getAllFeeds() as $feed) {
		echo $feed->getText().' - '.$feed->getXmlUrl().'';
	}
}

```

### Creating &amp; Exporting an OPML File

[](#creating--exporting-an-opml-file)

```
$document = ComradeOPML::newDocument();

$document->addCategory('News')
	->addFeed('Awesome News', 'http//awesome.news/rss')
	->addFeed('Good Times', 'http//good.times/rss')
	->addFeed('Best News', 'http//best.news/rss');

$document->addFeed('Food', 'Recipe Site', 'http://recipe.site/rss');
$document->addFeed('Food', 'Succulent Soups', 'http://succulent.soups/rss');

echo $document;

// # Or write to a file

ComradeOPML::exportFile($document, __DIR__.'/data/new.opml');

```

### Manipulating OPML Data

[](#manipulating-opml-data)

```
$document = ComradeOPML::newDocument();

$document->addCategory('Superfluous')
	->addFeed('Useless Things', 'http//uselesss.things/rss');

$document->addCategory('News')
	->addFeed('Horrible News', 'http//horribe.news/rss')
	->addFeed('Good Times', 'http//good.times/rss');

$document->removeCategory('Superfluous');
$document->getCategory('News')->removeFeed('http//horribe.news/rss');

```

Classes &amp; Methods
---------------------

[](#classes--methods)

### Innoscience\\ComradeOPML\\ComradeOPML

[](#innosciencecomradeopmlcomradeopml)

The `ComradeOPML` class is just a super-helpful factory class for ComradeOPML components.

`Comrade::importString($string)` : Import an OPML file in string format, returns a `Document`

`Comrade::importFile($filePath)` : Import an OPML file directly, returns a `Document`

`Comrade::newDocument()` : Creates a new `Document` instance. It's also a fancy way to write `new \Innoscience\ComradeOPML\Resource\Document`;

`Comrade::exportFile(Document $document, $filePath)` : Exports a `Document` to an OPML file

### Innoscience\\ComradeOPML\\Resource\\Document

[](#innosciencecomradeopmlresourcedocument)

The `Innoscience\ComradeOPML\Resource\Document` class, (we call it `Document` amongst friends) is where much of the magic happens.

`$document->addCategory($category, $title = '')` : Add a category, returns the created `Category` instance. The required `$category` argument is the `text` attribute, the `$title` is the `title` attribute.

`$document->getCategory($category)` : Get a category by its `text` attribute, returns the created `Category` instance.

`$document->getAllCategories()` : Get all categories, returns an array of `Category` instances.

`$document->removeCategory()` : Remove a category &amp; its feeds by its `text` attribute. Returns the `Document` instance.

`$document->addFeed($category, $text, $xmlUrl, $title = '', $htmlUrl = '', $type = 'rss')` : Adds a feed to the given category. Returns `Document` instance.

`$document->parse($xmlString)` : Parses OPML data into the `Document` instance, appending to the document if it has existing data. Returns the `Document` instance.

`$document->setDomInstance($instance)` : Pass an alternative instance of `DOMDocument` for exporting.

`$document->output()` : Returns the OPML formatted document.

`echo $document` : Same as above, returns the OPML formatted document.

##### Header Property Methods

[](#header-property-methods)

`$document->setTitle($string)` : Sets the `Document` `title` property in `head`

`$document->getTitle()` : Gets the `Document` `title` property in `head`

`$document->setDateCreated($string)` : Sets the `Document` `dateCreated` property in `head`

`$document->getDateCreated()` : Gets the `Document` `dateCreated` property in `head`

`$document->setDateModified($string)` : Sets the `Document` `dateModified` property in `head`

`$document->getDateModified()` : Gets the `Document` `dateModified` property in `head`

`$document->setOwnerName($string)` : Sets the `Document` `ownerName` property in `head`

`$document->getOwnerName()` : Gets the `Document` `ownerName` property in `head`

`$document->setOwnerEmail($string)` : Sets the `Document` `ownerEmail` property in `head`

`$document->setOwnerEmail()` : Gets the `Document` `ownerEmail` property in `head`

`$document->setExpansionState($string)` : Sets the `Document` `expansionState` property in `head`

`$document->getExpansionState()` : Gets the `Document` `expansionState` property in `head`

`$document->setVertScrollState($string)` : Sets the `Document` `vertScrollState` property in `head`

`$document->getVertScrollState()` : Gets the `Document` `vertScrollState` property in `head`

`$document->setWindowTop($string)` : Sets the `Document` `windowTop` property in `head`

`$document->getWindowTop()` : Gets the `Document` `windowTop` property in `head`

`$document->setWindowLeft($string)` : Sets the `Document` `windowLeft` property in `head`

`$document->getWindowLeft()` : Gets the `Document` `windowLeft` property in `head`

`$document->setWindowBottom($string)` : Sets the `Document` `windowBottom` property in `head`

`$document->getWindowBottom()` : Gets the `Document` `windowBottom` property in `head`

`$document->setWindowRight($string)` : Sets the `Document` `windowRight` property in `head`

`$document->getWindowRight()` : Gets the `Document` `windowRight` property in `head`

### Innoscience\\ComradeOPML\\Resource\\Category

[](#innosciencecomradeopmlresourcecategory)

`$category->addFeed($text, $xmlUrl, $title = '', $htmlUrl = '', $type = 'rss')` : Add a `Feed` to the `Category`, returns the `Category` instance.

`$category->getFeed($xmlUrl)` : Returns a `Feed` instance for the given feed.

`$category->getAllFeeds()` : Returns an array of `Feed` instances for the given `Category`

`$category->removeFeed($xmlurl)` : Removes the given feed from the `Category`

`$category->setText($string)` : Sets the `Category` `text` property, which is required. Returns the `Category` instance.

`$category->getText()` : Gets the `Category` `text` property.

`$category->setTitle($string)` : Sets the `Category` `title` property. Returns the `Category` instance.

`$category->getTitle()` : Gets the `Category` `title` property.

### Innoscience\\ComradeOPML\\Resource\\Feed

[](#innosciencecomradeopmlresourcefeed)

`$feed->getCategory()` : Returns the feed's `Category` `text` property

`$feed->getText()` : Returns the `Feed` `text` property

`$feed->setText($string)` : Sets the `Feed` `text` property

`$feed->getXmlUrl()` : Returns the `Feed` `xmlUrl` property

`$feed->setXmlUrl($string)` : Sets the `Feed` `xmlUrl` property

`$feed->getTitle()` : Returns the `Feed` `title` property

`$feed->setTitle($string)` : Sets the `Feed` `title` property

`$feed->getHtmlUrl()` : Returns the `Feed` `htmlUrl` property

`$feed->setHtmlUrl($string)` : Sets the `Feed` `htmlUrl` property

`$feed->getType()` : Returns the `Feed` `type` property

`$feed->setType($string)` : Sets the `Feed` `type` property

Tests
-----

[](#tests)

ComradeOPML is fully unit tested. Tests are located in the `tests` directory of the ComradeOPML package and can be run with `phpunit` in the package's base directory.

License
-------

[](#license)

ComradeOPML is licensed under GPLv2

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4434d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1737fa1e0d9eeac8c269552378baae6b17f491b20290da29d69f6575574d794a?d=identicon)[innoscience](/maintainers/innoscience)

---

Tags

rssopml

### Embed Badge

![Health badge](/badges/innoscience-comrade-opml/health.svg)

```
[![Health](https://phpackages.com/badges/innoscience-comrade-opml/health.svg)](https://phpackages.com/packages/innoscience-comrade-opml)
```

###  Alternatives

[spatie/laravel-feed

Generate rss feeds

9743.6M28](/packages/spatie-laravel-feed)[suin/php-rss-writer

Yet another simple RSS writer library for PHP 5.4 or later.

2651.4M20](/packages/suin-php-rss-writer)[thujohn/rss

RSS builder for Laravel 4

72130.0k3](/packages/thujohn-rss)[rumenx/php-feed

Framework-agnostic PHP Feed generator for Laravel, Symfony, and more.

3652.3k](/packages/rumenx-php-feed)[fkr/simplepie-bundle

Integrates SimplePie into Symfony

11137.5k](/packages/fkr-simplepie-bundle)[mitydigital/feedamic

A fully-featured RSS and Atom feed generator for Statamic.

1064.0k](/packages/mitydigital-feedamic)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
