PHP code example of 5dvision / directo

1. Go to this page and download the library: Download 5dvision/directo 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/ */

    

5dvision / directo example snippets




use Directo\Config;
use Directo\Client;

$client = new Client(new Config(
    token: 'your-api-token',
));

// List customers
$customers = $client->customers()->list();

// List items with filters
$items = $client->items()->list([
    'class' => 'ELECTRONICS',
    'ts' => '12.01.2026',
]);

// Create or update a customer using the Directo IN schema shape
$client->customers()->put([
    '@attributes' => [
        'code' => 'CUST001',
        'name' => 'Acme OU',
        'email' => '[email protected]',
    ],
]);

use Directo\Config;

$config = new Config(
    baseUrl: 'https://login.directo.ee/...', // Optional: Base URL
    token: 'your-api-token',                 // Required: API token
    tokenParamName: 'token',                 // 'token' or 'key' (default: 'token')
    timeout: 30.0,                           // Request timeout (default: 30s)
    connectTimeout: 10.0,                    // Connection timeout (default: 10s)
    validateSchema: false,                   // XSD validation (default: false)
    treatEmptyAsNull: true,                  // Empty string handling (default: true)
);

$client = new Client($config);