A fully featured wrapper for the MetroPublisher API.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


MetroPublisher SDK Beta

Build Status Codacy Badge License

This is a fully featured SDK for the MetroPublisherTM REST API. It takes care of the boilerplate HTTP client request/response logic for you so you can dive right into implementing the API into your app.


The recommended method of installation is through composer.

composer require michaeljamesparsons/metropublisher-php-sdk


If you are using composer, these dependencies should be installed automatically.


use MetroPublisher\MetroPublisher;
use MetroPublisher\Api\Models\Article;

//Create a new MetroPublisher API instance
$metroPublisher = new MetroPublisher("{public key}", "{secret key}");

//Create a new article
$article = new Article($metroPublisher);
    ->setTitle('Lorem Ipsum')
    ->setMetaTitle('Lorem Ipsum')
    ->setDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
    ->setMetaDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
    ->setPrintDescription('Lorem ipsum dolor sit amet, consectetur adipiscing elit.')
    ->setContent('<p>Quisque sed erat sed ex eleifend sollicitudin eu id ligula.</p>')
    ->setIssued(new DateTime('now'))

//Save the article

//Delete the article



A model represents an object in the MetroPublisher API. For example, this could be an article, event, location, or other object. The properties of these objects map to the fields defined for that object in the official API resource reference.

Resource Models

A resource model is a type of model which, unlike non-resource models, can be saved to the API or deleted from it. Some resource models have extra methods that allow them to fetch other models that are related to them. Not all of the resource models have been implemented, but I've listed the ones that are ready for you below!

  • Article
  • Event
  • AlbumReview
  • BookReview
  • LocationReview
  • Location
  • Tag
  • TagCategory
  • Slot
  • ExternalSlotMedia
  • EmbedSlotMedia
  • FileSlotMedia

Non-Resource Models

Non-resource models are dependent on another resource model to exist. For example, the path_history model cannot be saved or deleted from the API. It simply represents meta-data from another model.

  • PathHistory


Each resource model has a corresponding collection object. A collection object allows you to fetch groups of a resource model, an individual resource model, or groups of models that are related to the resource model.

use MetroPublisher\Api\Collections\ArticleCollection;

$articleCollection = new ArticleCollection($metroPublisher);

//Get group of articles
$articles = $articleCollection->findAll();
//Get next group of articles
$moreArticles = $articleCollection->findAll(2);

//Get a single article
$singleArticle = $articleCollection->find('e6ebac9c-94cb-11e6-ae22-56b6b6499611');


Unit tests are located in the /tests directory. Full coverage is in progress.



  • Implement HttpClient interface
  • Cache parsed model annotations
  • Support directly associating objects along side UUIDs
  • Make collections iterable


Released under the MIT license.