PHP code example of goatandcow7 / pennylane-sdk

1. Go to this page and download the library: Download goatandcow7/pennylane-sdk 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/ */

    

goatandcow7 / pennylane-sdk example snippets


use Pennylane\Sdk\Pennylane;
use Pennylane\Sdk\Filter;

$client = new Pennylane(); // reads PENNYLANE_API_TOKEN

// List and filter, with transparent pagination
foreach ($client->customerInvoices->list(
    filter: [Filter::gte('date', '2026-01-01')],
    sort: '-date',
) as $invoice) {
    echo $invoice->invoiceNumber, ' ', $invoice->currencyAmount, PHP_EOL;
}

// Create, finalize, send
$invoice = $client->customerInvoices->create(
    date: '2026-07-08',
    deadline: '2026-08-07',
    customerId: 123,
    invoiceLines: [['product_id' => 45, 'quantity' => '2']],
);
$client->customerInvoices->finalize($invoice->id);
$client->customerInvoices->sendByEmail($invoice->id);

use Pennylane\Sdk\PennylaneFirm;

$firm = new PennylaneFirm(); // reads PENNYLANE_FIRM_API_TOKEN

foreach ($firm->companies->list() as $company) {
    foreach ($firm->trialBalance->list(
        $company->id,
        periodStart: '2026-01-01',
        periodEnd: '2026-06-30',
    ) as $row) {
        // ...
    }
}

use Pennylane\Sdk\FileUpload;

$client->customerInvoices->sendToPa($invoice->id);                                   // emit through the PA
$client->supplierInvoices->importEInvoice(FileUpload::fromPath('factur-x.pdf'));     // ingest Factur-X/UBL/CII