Download the PHP package weble/ptv-php without Composer
On this page you can find all versions of the php package weble/ptv-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download weble/ptv-php
More information about weble/ptv-php
Files in weble/ptv-php
Informations about the package ptv-php
PHP SDK for the PTV APIs
This is an SDK for the PTV API.
It currently implements partially the Data API and the Routing API.
Under the hood it uses Saloon to handle the requests.
It features only 2 dependencies:
saloonphp/saloon
to handle the requests and the SDK building in generalmoneyphp/money
to represent the prices and currencies
Every parameter and response object is carefully mapped with a dedicated DTO class and Enum
Installation
composer require weble/ptv-php
Basic Usage
Just create the client and interact with each of the apis.
Setting a language
Data Api
Only 3 endpoints are implemented as of today:
1. vehicleProfiles
2. vehicleModels
3. mapInformation
Routing Api
Currently only 3 endpoints are supported:
1. calculate
This is by far the most complete one and the most likely used. You can calculate a route by chaining parameters within the call.
Each parameter is typed for full IDE autocompletion and ease of use.
2. recalculate
Uses a previously returned Route Id to recalculate parts of the route results
Get Route
Get previously calculated route details, or even an alternative route detail.
The route object
The Route
object is a fully typed DTO to ease reading the results of the APIs
Testing
To test you can just run
composer test
It will use fixture json to test the SDK.
If you want you can also set a .env
file with a dedicated PTV key and do some real testing with the API.