Warning
This package does not currently contain tests - these are a work-in-progress hence version number. Tests will be created in due course.
A PHP library for interacting with the DVLA API. Please ★ this package if you found it useful :)
The recommended way to install this library is through Composer.
This will install the latest supported version:
$ composer require kilosierracharlie/driverandvehiclelicensingWhen 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.
You can use this package in a standalone fashion, or as part of a framework such as Symfony or Laravel.
<?php
use KiloSierraCharlie\DriverAndVehicleLicensing\VehicleEnquiryService;
$ves = new VehicleEnquiryService( "API_KEY" );
$result = $ves->getVehicleData( "AB12 CDE" );
$result->motStatus; # KiloSierraCharlie\DriverAndVehcicleLicensing\Models\MOTStatus::NOT_VALIDFirstly 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=abcdefghijklmnop12345services.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
]);
}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.