Trainjunkies - HSP
, (*1)
PHP API to consume National Rail Historical Services Performance API., (*2)
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. Also instructions on consuming the API in your project., (*3)
Installation
To consume the NRE Data Feeds in your project, require the package via composer., (*4)
composer.phar require trainjunkies/hsp
To query the API configure the Client
with your own API credentials from National Rail Datafeeds, (*5)
<?php
include __DIR__ . '/vendor/autoload.php';
$client = \Trainjunkies\Hsp\ClientFactory::create(
'USERNAME',
'PASSWORD'
);
try {
$result = $client->getServiceDetails('SOME-RID-VALUE');
} catch (Exception $e) {
die($e->getMessage());
}
Development / Testing installation
For development you will require your flavour of Docker and Git installed., (*6)
git clone git@github.com:trainjunkies/hsp.git
And in the directory where you'e cloned the project..., (*7)
docker-compose up -d --build
This will provision the hsp
container, installing required PHP libraries & Xdebug., (*8)
Running the tests
Explain how to run the automated tests for this system, (*9)
Unit/Spec tests
docker-compose run --rm hsp bin/phpspec r
Integration suite
To query a valid Service Details request against the HSP API, (*10)
docker-compose run --rm hsp bin/phpunit
Code style checker
For consistency..., (*11)
docker-compose run --rm hsp bin/phpcs --standard=PSR2 src/
Debugging with Xdebug
Xdebug is enabled within the container by default with the settings specified in docker-compose.yml
, (*12)
By default Xdebug will attempt to connect to 10.254.254.254
on port 9000
. To facilitate this you can alias 127.0.0.1
to this address using the below instructions., (*13)
sudo ifconfig lo0 alias 10.254.254.254
Ubuntu
sudo ifconfig lo:1 10.254.254.254 up
You should now be able to use Xdebug by setting PHPStorm to listen for connections., (*14)
NOTE: The path mapping should be /var/www
to your project directory.
NOTE: Further configuration to your IDE might be required to listen to incomming Xdebug connections. With the below example in PHPStorm a "server" needs to be defined for trainjunkies_hsp_dev_container
, (*15)
docker-compose run --rm -e PHP_IDE_CONFIG="serverName=trainjunkies_hsp_dev_container" hsp bin/phpspec r spec/Trainjunkies/Hsp/ClientSpec.php
Contributing
Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us., (*16)
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository., (*17)
Authors
See also the list of contributors who participated in this project., (*18)
License
This project is licensed under the MIT License - see the LICENSE.md file for details, (*19)