kilosierracharlie / driverandvehiclelicensing
A PHP library for interacting with the DLVA APIs.
Requires
- guzzlehttp/guzzle: ^7.9
Requires (Dev)
- phpunit/phpunit: ^12
This package is auto-updated.
Last update: 2025-08-12 00:48:07 UTC
README
Warning
This package does not currently contain tests - these are a work-in-progress hence version number. Tests will be created in due course.
Driver & Vehicle Licensing Agency (DVLA) API
A PHP library for interacting with the DVLA API. Please ★ this package if you found it useful :)
Installation
The recommended way to install this library is through Composer.
This will install the latest supported version:
$ composer require kilosierracharlie/driverandvehiclelicensing
Configuration
When initiating the API classes you'll be required to pass the following details, which will be visible to the certificate holder:
Variable | Description | Required for |
---|---|---|
API_KEY | The API key issued by the DVLA to you. | Vehicle Enquiry Service |
API_JWT* | The JWT generated by you every 365 days. | Access to Driver Data |
*At present, the JWT key is not utilised within the API as Access to Driver Data is not implemented.
Example Use
You can use this package in a standalone fashion, or as part of a framework such as Symfony or Laravel.
Standalone Use
<?php use KiloSierraCharlie\DriverAndVehicleLicensing\VehicleEnquiryService; $ves = new VehicleEnquiryService( "API_KEY" ); $result = $ves->getVehicleData( "AB12 CDE" ); $result->motStatus; # KiloSierraCharlie\DriverAndVehcicleLicensing\Models\MOTStatus::NOT_VALID
Symfony Use
Firstly you'll need to configure the service, the easiest way would be to use the AutoWire to pass environment variables. You could manually create an instance of the APIs in your class and pass these from another object such as a database, if required.
.env:
DVLA_API_KEY=abcdefghijklmnop12345
services.yaml:
services: ... KiloSierraCharlie\DriverAndVehicleLicensing\VehicleEnquiryService: arguments: - '%env(DVLA_API_KEY)%'
In your controller/command etc:
use KiloSierraCharlie\DriverAndVehicleLicensing\UpdateServiceAPI; ... #[Route('/check_mot', name: 'check_mot')] public function check_mot( VehicleEnquiryService $ves, Request $request ){ ... $result = $ves->getVehicleData( $request->query->get("VEHICLE_REGISTRATION") ); return $this->json([ 'current' => $result->taxStatus, # KiloSierraCharlie\DriverAndVehcicleLicensing\Models\MOTStatus::VALID 'expiry' => $result->taxDueDate # DateTimeImmutable ]); }
API Key
You can apply for the DVLA API key for the Vehicle Enquiry Service here.
You can generate a DVLA JWT key once you've onboarded with the DVLA's API team. Details available here.