harmonicdigital/ldbws 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

harmonicdigital/ldbws

最新稳定版本:0.1.0

Composer 安装命令:

composer require harmonicdigital/ldbws

包简介

An implementation to consume the Live Departure Board Web Service by National Rail

README 文档

README

A lightweight PHP 8.3+ client for the National Rail UK Live Departure Board Web Service (LDBWS).

This library wraps the official REST endpoints exposed via Rail Data Marketplace and provides typed responses for station boards. It uses Guzzle under the hood and follows PSR-3 for logging.

  • Package name: harmonicdigital/ldbws
  • Minimum PHP: 8.3
  • Transport: Guzzle (PSR-18 compatible via guzzlehttp/guzzle), PSR-3 logging

Installation

Install via Composer:

composer require harmonicdigital/ldbws

You will need an API key for the Rail Data Marketplace (LDBWS). Supply it when constructing the client.

Features

Currently implemented service methods in HarmonicDigital\Ldbws\LdbwsClient:

  1. getDepartureBoard() — Fetch a basic departure board for a station.

Example:

<?php

use HarmonicDigital\Ldbws\LdbwsClient;
use HarmonicDigital\Ldbws\Response\FilterType;

$client = new LdbwsClient(apiKey: 'YOUR_API_KEY');

// Get the next 5 departures from London Euston (EUS) heading to Watford Junction (WFJ)
$board = $client->getDepartureBoard(
    'EUS',            // CRS code for the station
    5,            // up to 150
    'WFJ',      // optional filter station CRS
    FilterType::TO, // or FilterType::From
    0,         // minutes before/after current time (-120 to 120)
    60,        // window of results in minutes (0 to 120)
);

// $board is an instance of HarmonicDigital\Ldbws\Response\StationBoard
// Iterate services, times, destinations, etc.
  1. getDepartureBoardWithDetails() — Fetch a departure board including calling point details for services.

Example:

<?php

use HarmonicDigital\Ldbws\LdbwsClient;
use HarmonicDigital\Ldbws\Response\FilterType;

$client = new LdbwsClient(apiKey: 'YOUR_API_KEY');

$boardWithDetails = $client->getDepartureBoardWithDetails('EUS');

// $boardWithDetails is an instance of HarmonicDigital\Ldbws\Response\StationBoardWithDetails
// It includes additional detail per service (e.g., calling points)

All methods may throw:

  • HarmonicDigital\Ldbws\Exception\LdbwsFaultException when the API returns a known LDBWS fault
  • HarmonicDigital\Ldbws\Exception\LdbwsUnknownException for unexpected transport or server errors
  • HarmonicDigital\Ldbws\Exception\UnparseableResponseException when the response cannot be parsed

To Do

The following endpoints are present in the official swagger (config/ldbws-swagger.json) but are not yet implemented in LdbwsClient:

  • GetArrivalBoard
  • GetArrivalDepartureBoard
  • GetArrBoardWithDetails
  • GetArrDepBoardWithDetails
  • GetFastestDepartures
  • GetFastestDeparturesWithDetails
  • GetNextDepartures
  • GetNextDeparturesWithDetails
  • GetServiceDetails

Implemented already:

  • GetDepartureBoard
  • GetDepBoardWithDetails (exposed as getDepartureBoardWithDetails)

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-15