PHPackages                             lendable/dvla-vehicle-enquiry-api-client - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. lendable/dvla-vehicle-enquiry-api-client

ArchivedLibrary[API Development](/categories/api)

lendable/dvla-vehicle-enquiry-api-client
========================================

API client for the DVLA's Vehicle Enquiry Service API

v1.0.1(4y ago)553.9k2[1 issues](https://github.com/Lendable/dvla-vehicle-enquiry-api-client/issues)[8 PRs](https://github.com/Lendable/dvla-vehicle-enquiry-api-client/pulls)proprietaryPHPPHP &gt;=7.4.0CI passing

Since Aug 4Pushed 1w ago40 watchersCompare

[ Source](https://github.com/Lendable/dvla-vehicle-enquiry-api-client)[ Packagist](https://packagist.org/packages/lendable/dvla-vehicle-enquiry-api-client)[ Docs](https://www.lendable.co.uk)[ RSS](/packages/lendable-dvla-vehicle-enquiry-api-client/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (15)Versions (13)Used By (0)

DVLA Vehicle Enquiry API client
===============================

[](#dvla-vehicle-enquiry-api-client)

[![Latest Stable Version](https://camo.githubusercontent.com/abf941cb6d78275b998bd0bbffe7f4971b21fa4862ab5b4ff89977576c7cd4ef/68747470733a2f2f706f7365722e707567782e6f72672f6c656e6461626c652f64766c612d76656869636c652d656e71756972792d6170692d636c69656e742f762f737461626c65)](https://packagist.org/packages/lendable/dvla-vehicle-enquiry-api-client)[![License](https://camo.githubusercontent.com/20dd7194ce9573f681e388816d5121cde8cedd93841f57c5eb4a4349c3e133bc/68747470733a2f2f706f7365722e707567782e6f72672f6c656e6461626c652f64766c612d76656869636c652d656e71756972792d6170692d636c69656e742f6c6963656e7365)](https://packagist.org/packages/lendable/dvla-vehicle-enquiry-api-client)

PHP client implementation for the DVLA Vehicle Enquiry API v1. This package provides:

- API client that supports PSR-18 HTTP clients
- token-based authentication
- value objects for the request building and for the response

Installation
------------

[](#installation)

You can install the library via [Composer](https://getcomposer.org/).

```
composer require lendable/dvla-vehicle-enquiry-api-client
```

Usage
-----

[](#usage)

The [Client](https://github.com/Lendable/dvla-vehicle-enquiry-api-client/blob/main/src/Client.php) class implements the DVLA's REST API and can return the [vehicles scope](https://github.com/Lendable/dvla-vehicle-enquiry-api-client/blob/main/src/Scope/VehiclesScope/VehiclesScope.php) which can be used to request the vehicle details.

For the instantiation of the [Client](https://github.com/Lendable/dvla-vehicle-enquiry-api-client/blob/main/src/Client.php) class we need to inject the decorators which adds the API key authentication, and the PSR-18 compatibility layers. Also, we need to define the API's base URI to easily switch between UAT and live service.

### Base URI

[](#base-uri)

The [API's specification](https://developer-portal.driver-vehicle-licensing.api.gov.uk/apis/vehicle-enquiry-service/v1.1.0-vehicle-enquiry-service.html#vehicle-enquiry-api) contains the UAT and live URL. The given URI should not end with slash (`/`) and should contain the `/v1` path too.

For example: `https://uat.driver-vehicle-licensing.api.gov.uk/vehicle-enquiry/v1`

The client accepts the URI in any [PSR-7](https://www.php-fig.org/psr/psr-7/) UriInterface implementation.

### Authentication

[](#authentication)

The [ApiKeyAuthHttpClientDecorator](https://github.com/Lendable/dvla-vehicle-enquiry-api-client/blob/main/src/Auth/ApiKeyAuthHttpClientDecorator.php) adds the required API token authentication headers to the requests. The [ApiKey](https://github.com/Lendable/dvla-vehicle-enquiry-api-client/blob/main/src/Auth/ValueObject/ApiKey.php) value object keeps the token secret, avoiding accidental exposure.

### HTTP client

[](#http-client)

With the [Psr18ClientDecorator](https://github.com/Lendable/dvla-vehicle-enquiry-api-client/blob/main/src/Psr18ClientDecorator.php)you can use any HTTP client which supports the [PSR-18](https://www.php-fig.org/psr/psr-18/) standard to perform the prebuilt HTTP request.

If you prefer to use an HTTP client that doesn't support the PSR-18 standard, you can alternatively make a simple decorator that calls the HTTP client using the PSR-18 RequestInterface format request data and convert the HTTP client's response to a PSR-18 ResponseInterface format response.

For example in our [integration test](https://github.com/Lendable/dvla-vehicle-enquiry-api-client/blob/main/tests/Integration/ClientTest.php)we are using GuzzleClient with a [decorator](https://github.com/Lendable/dvla-vehicle-enquiry-api-client/blob/main/tests/Integration/Tool/GuzzlePsr18ClientDecorator.php) which using this PSR-18 conversion.

### Example request

[](#example-request)

```
