Download the PHP package invoicexml/zugferd-xrechnung without Composer

On this page you can find all versions of the php package invoicexml/zugferd-xrechnung. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package zugferd-xrechnung

ZUGFeRD and XRechnung for PHP

tests

A thin PHP client for the InvoiceXML API that creates, validates, embeds, renders, converts, emails and reads German e-invoices:

You send an invoice as a PHP array, and the API computes totals and the VAT breakdown, builds the XML and the PDF/A-3, and validates the result before returning it. Your project needs no PDF library, no XML builder and no Schematron tooling.

Installation

Requires PHP 8.1 or newer. Guzzle is used by default, and any PSR-18 HTTP client works.

Quick start

The result is a ZUGFeRD PDF/A-3 in the EN 16931 profile, already validated against the official rules.

Why InvoiceXML

Get an API key

Sign up at www.invoicexml.com to start a 30-day free trial with 100 credits. No credit card is needed. Plans are listed on the pricing page.

Usage

Invoices use the field names of the EN 16931 InvoiceDocument model from the OpenAPI specification. The API explorer documents every field. Every method that takes a file accepts a path on disk or a File object.

Create a ZUGFeRD PDF

To keep your own invoice layout, pass 'pdfUrl' => 'https://...' and the API embeds the XML into that PDF instead of rendering one.

Create an XRechnung

XRechnung needs the Leitweg-ID in buyerReference, a seller contact and electronic addresses for both parties.

The output uses UBL syntax by default. Pass ['syntax' => 'cii'] as the second argument for the CII syntax. Both pass the same German rules.

Validate

The API answers valid and invalid documents alike with a result, so check valid.

Each finding carries the following fields:

$result->data holds the verdict details, such as schemaValid, schematronValid and profile. $result->report is the field report: one row per invoice field with its value and its findings.

Get a validation report as PDF

$report->file is the printable report. $report->valid is true or false, or null if the response carried no verdict. A failed verdict is a normal result, not an exception. A missing or malformed file still throws ApiException. validationLanguage (en, de or fr) words the whole report.

The reference pages are ZUGFeRD report and XRechnung report.

Embed XML into an existing PDF

The XML is validated before embedding. Pass skipValidation: true to embed it as is.

Create a CII XML for your own PDF

To keep your own invoice layout, create the CII XML from the invoice, then embed it into your PDF:

The XML declares the EN 16931 profile, so embedZugferd() takes it as is. language (en, de or fr) words default texts such as payment terms. The reference page is create CII.

Create a UBL invoice

createUbl() takes the same invoice array, and profile picks the UBL profile and its rules (peppol-bis-3 when omitted). The reference page is create UBL.

Render an invoice XML as PDF

renderXmlToPdf() takes any invoice XML, XRechnung (UBL or CII), CII (such as the XML of a ZUGFeRD invoice) or UBL, and detects the format. language is en, de or fr. logoUrl prints your logo and includeQrCode: true prints the payment QR code. Rendering shows what the XML carries and does not validate it.

The reference page is render XML.

Convert between formats

Each route has its own method:

The methods that return a ZUGFeRD PDF take language (en, de or fr) for the labels of the PDF. Every method takes validationLanguage (en, de or fr), which words the findings of a failed conversion. A failed conversion throws ApiException, and $e->errors lists the violated rules.

Send an invoice by email

The API creates and validates the invoice like the create methods, then sends the file as a real email from your own address. The sender must be on a domain added and verified on the Verified email domains page of the dashboard.

emailXrechnung($invoice, $email, $options) sends an XRechnung the same way. To send a PDF and XML you already have, use emailEmbeddedZugferd(), which always validates the XML:

No file comes back. accepted means the email was handed over for delivery, not yet that the recipient's mail server received it. Keep messageId: it identifies the email when you ask about a delivery later.

A refused email throws ApiException with one of these errorCode values, and 4020, 4021 and 4022 are not billed:

Only a 429 is retried, because nothing was sent. A timeout or connection failure throws the HTTP client's own exception rather than ApiException, and the email may already have gone out, so check before you send it again.

The full guide is at Send an invoice by email.

Read incoming invoices

Extraction parses the embedded XML deterministically, with no AI involved. The returned invoice can go straight back into createZugferd() or createXrechnung().

Read a PDF invoice with AI

parseJson() reads any PDF invoice, typed, scanned or photographed, into the same invoice array, plus confidence scores from 0 to 1 and the language the invoice is written in (each null when not reported). Any language can come back, so language is not always a value the language option of the create and render methods takes (en, de or fr). AI reads the PDF, so a person must check the data before it is used. Embedded XML is ignored, so use extractJson() for a ZUGFeRD PDF. A 429 on this method is not retried automatically.

The reference page is parse to JSON.

Transform a PDF invoice

These methods take a PDF without embedded XML. AI reads the PDF, so a person must check the result before it is used.

transformToZugferd() takes language (en, de, fr or auto, the default, which follows the language of the invoice). By default the PDF is rendered from the data that was read and ends with an electronic invoice details section, so that data can be checked on the pages. Pass includeAdvancedProperties: false to leave the section out, or preserveOriginalPdf: true to keep the uploaded PDF as the visual layer. transformToXrechnung() requires the Leitweg-ID in buyerReference. Both take validationLanguage (en, de or fr), which words the findings of a refused invoice. A 429 on these methods is not retried automatically, so wait for Retry-After before calling again if you want to retry.

The reference pages are transform to ZUGFeRD and transform to XRechnung.

Examples

The examples overview for the list and how to run them.

Errors and rate limits

Any error status throws InvoiceXml\ZugferdXrechnung\ApiException. When a create or embed request is refused because the invoice would not be compliant, $e->errors lists the violated rules as findings.

errorCode is a stable numeric code, documented under error handling.

When too many requests for one API key run at the same time, the API answers 429 with a Retry-After header. Every call except transform and parse waits that long and resends the request, up to 3 times. A 429 is not billed. If the retries are used up, a TooManyRequestsException carries retryAfter in seconds. Set maxRetries: 0 to handle 429 yourself.

Configuration

Links

License

MIT


All versions of zugferd-xrechnung with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-json Version *
guzzlehttp/guzzle Version ^7.5
guzzlehttp/psr7 Version ^2.4
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package invoicexml/zugferd-xrechnung contains the following files

Loading the files please wait ...