SDKs
PHP & Laravel SDK
The official Wayline SDK for PHP & Laravel: PHP 8.1+. PSR-18 HTTP client and PSR-17 factories (bring your own, e.g. Guzzle). Laravel service provider and facade included.
Install
composer require wayline/wayline-phpQuickstart
Set WAYLINE_API_KEY to a test key (see the Quickstart), then:
<?php
use Wayline\Client;
$wayline = new Client(getenv('WAYLINE_API_KEY'));
$d = $wayline->distance([
'origin' => ['lat' => 23.7925, 'lng' => 90.4078],
'destination' => '23.733,90.4172',
'units' => 'imperial',
]);
echo $d['distance_miles'], ' mi, ', $d['duration_seconds'], " s\n";
// Laravel: set WAYLINE_API_KEY in .env, then
// use Wayline\Laravel\Facades\Wayline;
// Wayline::matrix(['origins' => [...], 'destinations' => [...]]);Errors
Non-2xx responses raise a typed error after retries are exhausted. Branch on code — the full list is in the error reference.
use Wayline\WaylineException;
try {
$wayline->distance(['origin' => '0,0', 'destination' => '0,1']);
} catch (WaylineException $e) {
echo $e->errorCode, ' ', $e->status, ' ', $e->requestId;
}Configuration
| Option | Default | Description |
|---|---|---|
| API key | WAYLINE_API_KEY | Your live or test key. Never logged. |
| Base URL | https://api.wayline.cloud | Override for staging or a proxy. |
| Timeout | 30 seconds | Per attempt. |
| Max retries | 3 | For 429 and 5xx, with exponential backoff + jitter, honoring Retry-After. |
Source and releases
Package: wayline/wayline-php on Packagist. Source: packages/sdk-php. Versions follow semantic versioning; see the CHANGELOG in the package and our product changelog.