PHP code example of mattsplat / vin-decode

1. Go to this page and download the library: Download mattsplat/vin-decode library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mattsplat / vin-decode example snippets


use Mattsplat\VinDecode\Vpic;

$vpic = new Vpic();

// Decode a VIN into one flat object
$vehicle = $vpic->decodeVinFlat('5UXWX7C5*BA', 2011);

$vehicle->make();            // "BMW"
$vehicle->model();           // "X3"
$vehicle->modelYear();       // 2011
$vehicle->bodyClass();       // "Sport Utility Vehicle (SUV)/Multipurpose Vehicle (MPV)"
$vehicle->engineCylinders(); // 6
$vehicle->get('PlantCity');  // "MUNICH" — any raw vPIC field

// List every model a make has registered
foreach ($vpic->modelsForMake('Honda') as $model) {
    echo $model->name, "\n";
}

$response = $vpic->allManufacturers(page: 2);

$response->count();          // rows in this response
$response->reportedCount;    // vPIC's own Count field
$response->message;          // vPIC status message
$response->first();          // first DTO, or null
$response->all();            // list<Manufacturer>

use GuzzleHttp\Client as GuzzleClient;
use Mattsplat\VinDecode\Client;
use Mattsplat\VinDecode\Vpic;

$vpic = new Vpic(new Client(new GuzzleClient([
    'timeout' => 5,
    // ... proxy, middleware, retry handler, etc.
])));

use VinDecode\VinDecode; // still works

$decode = new VinDecode();
$decode->setVIN('5UXWX7C5XBL41234');
$decode->searchVIN();     // snake_cased flat array, as before
echo $decode->make;