2017 © Pedro Peláez
 

library railtime

PHP client for Irish Rail's Realtime Rail XML web service.

image

daviddoran/railtime

PHP client for Irish Rail's Realtime Rail XML web service.

  • Monday, August 26, 2013
  • by daviddoran
  • Repository
  • 3 Watchers
  • 7 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Railtime Build Status

A PHP library for Irish Rail's Realtime API., (*1)

Usage

The main class exported by this package is \Railtime\API., (*2)

First, create a new API object:, (*3)

use \Railtime\API;

$api = new API;

Then, call the various API methods:, (*4)

$stations = $api->stations();

The API class exposes the following methods:, (*5)

Station[]           stations([$station_type])
RunningTrain[]      current_trains([$train_type])
StationPassing[]    station_passings($name_or_code[, $minutes = null])
TrainMovement[]     train_movements($train_id, $train_date)

Make sure to check out the Examples below., (*6)

Installing

This package is available from Packagist., (*7)

To install using Composer, add this to the "require": section of your composer.json file:, (*8)

"daviddoran/railtime": "dev-master"

Once you've installed Composer simply run:, (*9)

php composer.phar install

Or, if you installed composer globally:, (*10)

composer install

Tests

The unit tests are contained in test and the configuration in phpunit.xml., (*11)

After installing dependencies with composer, the following should run the tests:, (*12)

./vendor/bin/phpunit

Examples

Get a list of all the Dart stations

$stations = $api->stations(\Railtime\StationTypeDart);

Get the currently running Mainline trains

$trains = $api->current_trains(\Railtime\TrainTypeMainline);

Get a list of the trains passing Howth Junction (default next 90 minutes)

//You can use the station's full name
$passings = $api->station_passings("Howth Junction");

//Or use the station's code
$passings = $api->station_passings("HWTHJ");

Get a list of the trains passing Connolly in the next 15 minutes

//You can also use the station code "CNLLY"
$passings = $api->station_passings("Dublin Connolly", 15);

Get a list of a train's movements on a particular day

$movements = $api->train_movements("E815", "25 Aug 2013");

Check how early/late a train was at each station

$movements = $api->train_movements("E815", "18 Aug 2013");
foreach ($movements as $stop) {
    if (!$stop->is_origin()) {
        $mins = round($stop->arrival_diff_seconds() / 60);
        echo "-- ", abs($mins), " min ", ($mins > 0 ? "late" : "early"), " --> ";
    } else {
        echo "-- set off --> ";
    }
    echo $stop->location_fullname, "\n";
}

This will output something like:, (*13)

-- set off --> Greystones
-- 0 min early --> Bray
-- 0 min early --> Shankill
-- 1 min late --> Killiney
-- 1 min late --> Dalkey
-- 2 min late --> Glenageary
-- 2 min late --> Sandycove
-- ✂ -- ✂ -- snip -- ✂ -- ✂ --
-- 3 min late --> Kilbarrack
-- 3 min late --> Howth Junction
-- 2 min late --> Clongriffin
-- 2 min late --> Portmarnock
-- 2 min late --> Malahide

License

This project is released under the MIT License - see the LICENSE file for details., (*14)

The Versions

26/08 2013

dev-master

9999999-dev http://github.com/daviddoran/php-railtime

PHP client for Irish Rail's Realtime Rail XML web service.

  Sources   Download

MIT

The Requires

 

The Development Requires

xml irish rail realtime rail