easybill/zugferd-php

ZUGFeRD PHP SDK (Factur-X, XRechnung) - Convert PHP Objects to XML and back.

Installs: 133 221

Dependents: 2

Suggesters: 0

Security: 0

Stars: 48

Watchers: 18

Forks: 32

Open Issues: 0

Language:XSLT

v2.0.1 2024-03-11 09:52 UTC

README

Latest Stable Version Total Downloads Latest Unstable Version License Gitter

ZUGFeRD PHP SDK (Factur-X, XRechnung) - Convert PHP Objects to XML and back.

Look @ Tests for more details

Installation

The recommended way of installing this library is using Composer.

Add this repository to your composer information using the following command

composer require easybill/zugferd-php

Usage ZUGFeRD v1

Convert XML to PHP Objects:

use Easybill\ZUGFeRD\Reader;

$document = Reader::create()->getDocument('zugferd-file.xml');
echo $document->getHeader()->getId(); // Get invoice No.

Convert PHP Objects to XML:

use Easybill\ZUGFeRD\Builder;
use Easybill\ZUGFeRD\Model\Document;
 
$doc = new Document(Document::TYPE_COMFORT);
$doc->getHeader()->setId('RE1337'); // Set invoice No.

$xml = Builder::create()->getXML($doc);
echo $xml; // Zugferd XML.

Usage ZUGFeRD v2

Convert XML to PHP Objects:

use Easybill\ZUGFeRD2\Reader;

$xml = file_get_contents('factur-x.xml');
$obj = Reader::create()->transform($xml);

Convert PHP Objects to XML:

use Easybill\ZUGFeRD2\Builder;
 
$obj = ...;

$xml = Builder::create()->transform($obj);
echo $xml; // Zugferd XML.

Contributing

Please feel free to send bug reports and pull requests.

License

Published as open source under the terms of MIT License.