2017 © Pedro Peláez
 

library php-open-rail-data

A PHP libary for processing API events from the Open Rail Data initiative

image

neilmcgibbon/php-open-rail-data

A PHP libary for processing API events from the Open Rail Data initiative

  • Wednesday, June 3, 2015
  • by neilmcgibbon
  • Repository
  • 1 Watchers
  • 1 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

php-open-rail-data

A PHP library to consume data from the Open Rail Data initiative., (*1)

At present only Stomp (ActiveMQ) data for Network Rail is supported, but I will be adding support for Static Network Rail data (such as Schedule) and Stomp support for National Rail in the near future., (*2)

Installation

This is done via composer (packagist). Add the following to your composer.json file:, (*3)

{
  "require": {
     "neilmcgibbon/php-open-rail-data": "0.1.0"
  }
}

Currently supported data feeds:

  • Network Rail
    • ActiveMQ realtime feeds (via Stomp)
      • RTPPM - Real Time Passenger Performance Measurements
      • VSTP - Very Short Term Planning
      • Train Movements - Cancellations, Activations, Reinstatements, etc.
      • TD - Train Describer events

Feeds not yet supported

  • Network Rail, (*4)

    • ActiveMQ realtime feeds (via Stomp)
      • TSR - Temporary Speed Restrictions
    • Static feeds (via HTTP)
  • National Rail, (*5)

    • all feed types

Usage:

Stomp - Network Rail events

Events are processed via the observer / event dispatcher pattern, (*6)

Example:

To listen for Real Time Passenger Performance Measurements (RTPPM events), and then dump out the number of late trains on the "National Page" level:, (*7)

Create the event listener, (*8)

class ExampleEventListener
{

  public function onEventReceived(RtppmEvent $event)
  {
    echo "Received event. National page late trains count: ";
    echo $event->getNationalPage()->getPerformance()->getLateCount() . PHP_EOL;
  }
}

Create the connection and start listening, (*9)


$connection = new \OpenRailData\NetworkRail\Services\Stomp\Connection( "network_rail_username", "network_rail_password" ); // Create the Topic. $topic = new OpenRailData\NetworkRail\Services\Stomp\Topics\Rtppm\RtppmTopic(); // Add our event listener to the topic $topic->addListener(new ExampleEventListener()); // Subscribe to the topic by adding the topic to the connection $connection->addTopic($topic); // Start listening for events, the rest is handled by our event listener :-) $connection->listen();

And thats it!, (*10)

More documentation and functionality to follow. Please also see the /examples dir for more examples., (*11)

The Versions

03/06 2015

dev-master

9999999-dev

A PHP libary for processing API events from the Open Rail Data initiative

  Sources   Download

MIT

The Requires

 

The Development Requires

03/06 2015

0.1.0

0.1.0.0

A PHP libary for processing API events from the Open Rail Data initiative

  Sources   Download

The Requires

 

The Development Requires