kayschima/deutsche-bahn

Laravel package for Deutsche Bahn timetables

v1.0.1 2022-05-27 10:45 UTC

This package is auto-updated.

Last update: 2024-08-29 05:43:34 UTC


README

Latest Version on Packagist Total Downloads Build Status

"Deutsche Bahn" is a laravel package for timetables of german railway stations

Installation

Via Composer

$ composer require kayschima/deutsche-bahn

Publish the config file

$ php artisan vendor:publish --provider "Kayschima\DeutscheBahn\DeutscheBahnServiceProvider"

Usage

The usage of the package is quite simple:

DEUTSCHE_BAHN_API_TOKEN=YOUR_API_TOKEN

Facade

You can use three different functions in this package:

use Kayschima\DeutscheBahn\Facades\DeutscheBahn;

$arrivals = DeutscheBahn::getArrivals('8000050', new DateTime('now'),true);
$departures = DeutscheBahn::getDepartures('8000050', new DateTime('now'), false);
$trainDetails = DeutscheBahn::getDetails('8000050hewrl7127871329172023440423023lhlhllklhlh50');

The first two functions expect

  • an id a train station in Germany (in this example 'Bremen')
  • a DateTime instance for date and time of the arrivals/departures
  • a boolean (details of the train wanted of not)

If you want to know details about a specific train journey, enter the id of that train journey in the 'getDetails' function. You might get these ids by calling 'getArrivals' or 'getDepartures' before.

All functions return an array as a result. In later versions of the package we will also pass the results of the REST call on to the user.

Until then, an empty array is returned as the function result if an error occurs when calling the Deutsche Bahn api or the function has generally not determined any results.

Artisan command

This package also provides an artisan coommand to get the id of a certain railway station of Deutsche Bahn.

php artisan deutsche-bahn:railway-station

Just answer the question about the desired train station and a number of possible IDs will be displayed.

Change log

Please see the changelog for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see contributing.md for details and a todolist.

Security

If you discover any security related issues, please email author email instead of using the issue tracker.

Credits

License

license. Please see the license file for more information.