Production-ready PHP 8.2+ SDK for the Directo XMLCore API. Directo XMLCore Documentation
MIT License. See LICENSE for details.
- 🚀 Simple API - Ergonomic, fluent interface for all endpoints
- 🔒 Type-safe - Strict types, PSR-12 compliant, IDE-friendly
- ✅ Testable - Full Guzzle MockHandler support
- 📋 Extensible - Add new endpoints in 5 minutes
- 🛡️ Validated - Optional XSD schema validation
- 🔧 Configurable - Flexible auth, timeouts, and response handling
- PHP 8.2+
- ext-dom
- ext-libxml
- guzzlehttp/guzzle ^7.0
| Topic | Description |
|---|---|
| Endpoints | |
| Customers | Customer records API (list, put, putBatch) |
| Items | Item/product records API (list, put, putBatch) |
| Receipts | Payment receipt records API (list) |
| Guides | |
| Schema Validation | XSD validation configuration |
| Error Handling | Exception types and handling |
| Testing | Unit and integration testing |
| Adding Endpoints | Extending the SDK |
composer require 5dvision/directo<?php
use Directo\Config;
use Directo\DirectoClient;
$client = new DirectoClient(new Config(
token: 'your-api-token',
));
// List customers
$customers = $client->customers()->list();
// List items with filters
$items = $client->items()->list([
'class' => 'ELECTRONICS',
'closed' => 0,
]);
// Create/update a record
$result = $client->items()->put([
'kood' => 'ITEM001',
'nimetus' => 'New Product',
'hind' => 99.99,
]);use Directo\Config;
$config = new Config(
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 DirectoClient($config);📖 Error handling documentation
use Directo\DirectoClient;
use Directo\Transport\MockTransport;
$transport = new MockTransport('<results><item><kood>TEST</kood></item></results>');
$client = DirectoClient::withTransport($transport);
$items = $client->items()->list();
// Returns: [['kood' => 'TEST']]./vendor/bin/pest