PHP code example of andregrunert-ctrl / zugferd-client

1. Go to this page and download the library: Download andregrunert-ctrl/zugferd-client 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/ */

    

andregrunert-ctrl / zugferd-client example snippets




ugferd\ZugferdClient;

// Initialisierung (nutzt automatisch den kostenlosen Test-Key)
$client = new ZugferdClient();

// Rechnungsdaten gemäß EN 16931
$invoiceData = [
    'invoice_number' => 'RE-2026-001',
    'issue_date' => '2026-10-10',
    'currency' => 'EUR',
    'seller' => [
        'name' => 'Muster GmbH',
        'street' => 'Hauptstraße 1',
        'zip_code' => '10115',
        'city' => 'Berlin',
        'country' => 'DE',
        'vat_id' => 'DE123456789',
        'iban' => 'DE12345678901234567890'
    ],
    'buyer' => [
        'name' => 'Kunden AG',
        'street' => 'Nebenstraße 2',
        'zip_code' => '80331',
        'city' => 'München',
        'country' => 'DE'
    ],
    'line_items' => [
        [
            'description' => 'Web-Entwicklung & E-Rechnung Integration',
            'quantity' => 10,
            'unit_price' => 120.00,
            'tax_rate_percent' => 19
        ]
    ]
];

// 1. ZUGFeRD PDF/A-3 Rechnung generieren und speichern
$pdfBytes = $client->generateInvoice($invoiceData, 'rechnung.pdf');
echo "✅ ZUGFeRD-Rechnung erfolgreich gespeichert!\n";

// 2. Rechnung validieren
$report = $client->validate('rechnung.pdf');
if ($report->isValid()) {
    echo "✅ Konform nach EN 16931 (" . $report->getFormat() . ")\n";
} else {
    echo "❌ Fehler: " . implode(', ', $report->getErrors()) . "\n";
}

$client->embedInvoice('mein_shop_beleg.pdf', $invoiceData, 'zugferd_fertig.pdf');

$client = new ZugferdClient('zg_live_mein_api_key');