Download the PHP package nikba/laravel-bussystem-api without Composer
On this page you can find all versions of the php package nikba/laravel-bussystem-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download nikba/laravel-bussystem-api
More information about nikba/laravel-bussystem-api
Files in nikba/laravel-bussystem-api
Package laravel-bussystem-api
Short Description Laravel package providing seamless integration with BusSystem transportation services
License MIT
Homepage https://github.com/Nikba-Creative-Studio/Laravel-Bussystem-Api
Informations about the package laravel-bussystem-api
Laravel BusSystem API
A typed Laravel client for the BusSystem passenger transportation API. Search bus, train, and air routes; build bookings; manage orders and tickets; and optionally persist API data with the included Eloquent models.
Highlights
- Laravel-native service container binding and facade
- Fluent, typed builders for route searches and bookings
- Bus, train, and air transport support
- Seat plans, discounts, baggage, reservations, payments, and cancellations
- Automatic caching for points, routes, and seat plans
- Configurable retries for transient API failures
- JSON and XML response parsing
- Optional order and ticket migrations and Eloquent models
- Dedicated exception hierarchy for predictable error handling
Requirements
- PHP 8.2+ (PHP 8.3+ with Laravel 13)
- Laravel 10, 11, 12, or 13
- Guzzle 7.5 or 8.x
Laravel 10 and 11 are supported for compatibility with existing applications but are end-of-life upstream. Prefer a currently maintained Laravel release for production deployments.
Installation
Install the package with Composer:
Laravel discovers the service provider and facade automatically.
Publish the configuration file:
If you want to store orders and tickets locally, publish and run the included migrations:
Configuration
Add your BusSystem credentials to .env:
The package also supports these optional settings:
BUSSYSTEM_RETRY_DELAY and cache TTL values are expressed in milliseconds and seconds, respectively. Keep credentials out of source control and use separate credentials for test and production environments.
Quick start
1. Search for routes
City and station identifiers are provided by BusSystem. You can retrieve available points before searching:
2. Check seats and booking options
Use the interval_id returned by the route search:
3. Create an order
Route and passenger indexes are zero-based when assigning seats, discounts, baggage, or wagons.
4. Buy or reserve tickets
Treat response arrays as external API data: validate the keys required by your application before reading or persisting them.
Dependency injection
For application services and controllers, dependency injection is usually preferable to the facade:
The client is registered as a singleton under BusSystemClientInterface and the bussystem container alias.
Route searches
SearchCriteria supports the following fluent methods:
| Purpose | Methods |
|---|---|
| Travel date | date(), period() |
| City route | from(), to() |
| Train stations | trainFrom(), trainTo() |
| Airport route | airportFrom(), airportTo() |
| Specific stations | stationFrom(), stationTo() |
| Transport | transport(), bus(), train(), air() |
| Transfers | allowTransfers(), directOnly() |
| Result options | sortBy(), sortByTime(), sortByPrice(), includeSoldOut() |
| Locale | currency(), language() |
| Air travel | airPassengers(), airServiceClass(), airDirect(), airBaggage() |
| Custom API data | addParam() |
For air travel, use IATA codes and the dedicated passenger options:
Booking builder
BookingData provides methods for composing single-leg or multi-leg bookings:
| Purpose | Methods |
|---|---|
| Routes | addRoute() |
| Passengers | addPassenger() |
| Seats | addSeat(), addSeats() |
| Discounts and baggage | addDiscount(), addBaggage() |
| Train wagon | addWagon() |
| Contact details | setContactInfo() |
| Additional details | setAdditionalInfo(), setPromocode() |
| Locale | setCurrency(), setLanguage() |
| Inspection | toArray(), validate(), getPassengerCount(), getRouteCount() |
For a multi-leg journey, call addRoute() once per leg and use its zero-based index for related selections:
Available operations
All methods are available through either BusSystemClientInterface or the BusSystem facade.
For signatures, parameters, builders, models, and configuration details, see the complete API reference.
| Method | Description |
|---|---|
getPoints() |
Retrieve cities, stations, and airports |
getRoutes() |
Search for available routes |
getAllRoutes() |
Retrieve detailed timetable routes |
getFreeSeats() |
Retrieve available seats or train wagons |
getSeatPlan() |
Retrieve a seat-plan layout |
getDiscounts() |
Retrieve discounts for a route |
getBaggage() |
Retrieve baggage options for a route |
createOrder() |
Create an order from BookingData |
buyTickets() |
Purchase tickets for an order |
reserveTickets() |
Reserve tickets for payment on boarding |
validateReservation() |
Check whether a phone number can reserve |
validateSms() |
Send or verify an SMS validation code |
getOrder() |
Retrieve order information |
getTicket() |
Retrieve ticket information |
cancelTickets() |
Cancel an order or selected tickets |
ping() |
Check API availability |
Enums
Native PHP enums remove common magic strings while preserving string-based compatibility:
TransportType:All,Bus,Train,AirSortType:Time,PriceResponseFormat:Json,XmlOrderStatus:Reserve,ReserveOk,Buy,CancelTicketStatus:Reserve,ReserveOk,Buy,Cancel
Unknown transport values fall back to TransportType::All; unknown sort values fall back to SortType::Time. Unknown model status values resolve to null.
Error handling
Every package exception extends BusSystemException and can carry structured context:
The exception namespace also includes booking, payment, and cancellation exception types for application-level workflows.
Caching, retries, and logging
Caching applies automatically to points, route searches, and seat plans when enabled. Cache keys include the request parameters, and each resource has its own configurable TTL.
The default HTTP client retries connection failures and HTTP 5xx responses using exponential backoff. BUSSYSTEM_RETRY_ATTEMPTS controls the maximum retry count and BUSSYSTEM_RETRY_DELAY sets the base delay in milliseconds.
Request logging is configurable through BUSSYSTEM_LOGGING_ENABLED, BUSSYSTEM_LOG_CHANNEL, and BUSSYSTEM_LOG_LEVEL. Authentication parameters are removed from request log context by the package. Review your logging retention and access policies because other booking data may contain personal information.
Optional Eloquent models
The package includes Order and Ticket models backed by bussystem_orders and bussystem_tickets. API responses are not persisted automatically; your application decides what and when to store.
Useful scopes include:
Order:active(),reserved(),paid(),expired(),forUser()Ticket:active(),reserved(),paid(),forPassenger(),forRoute(),departingAfter(),departingBefore()
Both models use soft deletes and retain the original API payload in the nullable api_response JSON column.
Testing
The injectable HTTP client in BusSystemClient makes isolated tests straightforward:
Run the project checks locally:
Individual commands are also available:
Contributing
Contributions are welcome. Please read CONTRIBUTING.md before opening a pull request and include tests for behavioral changes.
Security
Do not report security vulnerabilities through public issues. Follow SECURITY.md to disclose them privately.
Changelog
See CHANGELOG.md for release history and upgrade notes.
Credits
License
Laravel BusSystem API is open-source software licensed under the MIT License.
All versions of laravel-bussystem-api with dependencies
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
guzzlehttp/guzzle Version ^7.5|^8.0