PHP code example of bambamboole / gaeb

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

    

bambamboole / gaeb example snippets


$gaeb = GaebParser::fromString(file_get_contents('tender.x83'));
// returns a GaebFile; the library itself never touches the filesystem

$gaeb->info;      // GaebInfo
$gaeb->project;   // ProjectInfo
$gaeb->boq;       // ?BoQ

foreach ($gaeb->boq->allItems() as $item) { ... }   // lazy, flattened

$gaeb->owner;      // ?Party — client (Auftraggeber, OWN)
$gaeb->contractor; // ?Party — contractor/bidder (Auftragnehmer, CTR)
$gaeb->award;      // ?AwardData — populated from AwardInfo on any phase; meaningfully filled (dates, duration) on X86

$gaps = array_values(array_filter($item->textComplements, fn ($c) => $c->kind === TextComplementKind::Bidder));

use Bambamboole\Gaeb\GaebDocument;
use Bambamboole\Gaeb\Write\Bid;
use Bambamboole\Gaeb\Dto\Party;

$tender = GaebDocument::fromString(file_get_contents('tender.x83'));

$contractor = new Party(
    name: 'ACME Bau GmbH',
    street: 'Musterstraße 1',
    zip: '12345',
    city: 'Berlin',
    email: '[email protected]',
    phone: '+49 30 1234567',
);

$bid = new Bid($contractor, currency: 'EUR', date: '2026-07-31');
// currency defaults to the source's currency, date defaults to today —
// pass both explicitly for a byte-deterministic output.
// progSystem: 'my-erp 1.0' overrides the <ProgSystem> stamp
// (default 'bambamboole/gaeb'); Invoice takes the same option.

$bid->setUnitPrice('01.02.0010', '12.50')   // decimal strings are exact, floats convenient
    ->fillGap('01.02.0010', 1, 'Musterhersteller GmbH')
    ->setComment('01.02.0010', 'Lieferzeit 4 Wochen')
    ->setNotOffered('01.02.0020');          // spec 4.6.4: distinct from UP 0.00
// ...one setUnitPrice() or setNotOffered() per priceable item (every item
// that isn't marked notApplicable) — createBid() throws GaebWriteException
// naming any that's missing a price, any rNo it doesn't recognize, or any
// position that is both priced and marked not offered.

$award = $tender->createBid($bid);

$errors = $award->validate();   // [] means schema-valid
if ($errors !== []) {
    throw new RuntimeException(implode("\n", $errors));
}

file_put_contents('bid.x84', (string) $award);

use Bambamboole\Gaeb\Dto\InvoiceType;
use Bambamboole\Gaeb\Dto\Payment;
use Bambamboole\Gaeb\GaebDocument;
use Bambamboole\Gaeb\Write\Invoice;

$contract = GaebDocument::fromString(file_get_contents('contract.x86'));

$invoice = new Invoice(
    invoiceNo: 'RE-2026-001',
    invoiceDate: '2026-10-31',
    type: InvoiceType::Deduction,           // Abschlagsrechnung
    servicePeriodStart: '2026-09-01',
    servicePeriodEnd: '2026-10-31',
    creatorTaxNo: 'DE123456789',
    vatPercent: '19',                       // falls back to the contract's Totals/VAT
);
$invoice->billQty('01.0010', '30')          // CUMULATIVE billed quantities
    ->addPayment(new Payment(               // prior payments, emitted as PaymentMade
        total: '1190.00', totalVat: '190.00',
        discountAmount: null,
        paymentDate: '2026-10-05', invoiceNo: 'RE-2026-000',
    ));

$x89 = $contract->createInvoice($invoice);  // new GaebDocument, source untouched
$x89->validate();                           // [] — schema-valid against the official X89 XSD

$contract = GaebDocument::fromString(file_get_contents('contract.x86'));
$x89  = $contract->createInvoice($invoice);            // the full GAEB invoice
$x89b = $contract->createSupportingDocument($invoice); // the e-invoice attachment
$x89b->validate();  // [] — against the bundled X89B XSD

$contract = GaebDocument::fromString(file_get_contents('contract.x86'));
$x87 = $contract->createOrderConfirmation(date: '2026-06-20');  // source untouched
$x87->validate();  // []

$parser = new GaebParser([new MyDriver, new GaebXmlDriver]);
$gaeb = $parser->parse($content);