dev-master
9999999-dev http://github.com/daviddoran/php-railtimePHP client for Irish Rail's Realtime Rail XML web service.
MIT
The Requires
- php >=5.3.0
- rmccue/requests dev-master
The Development Requires
by David Doran
xml irish rail realtime rail
Wallogit.com
2017 © Pedro Peláez
PHP client for Irish Rail's Realtime Rail XML web service.
A PHP library for Irish Rail's Realtime API., (*1)
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)
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
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
$stations = $api->stations(\Railtime\StationTypeDart);
$trains = $api->current_trains(\Railtime\TrainTypeMainline);
//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");
//You can also use the station code "CNLLY"
$passings = $api->station_passings("Dublin Connolly", 15);
$movements = $api->train_movements("E815", "25 Aug 2013");
$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
This project is released under the MIT License - see the LICENSE file for details., (*14)
PHP client for Irish Rail's Realtime Rail XML web service.
MIT
xml irish rail realtime rail