The gap
An EN 16931 invoice has to be correct XML in UBL 2.1 or CII, and it also has to follow the business rules of the standard. Checking both from a PHP application usually means calling out to separate tools.
API
A free PHP library that writes and validates EN 16931 e-invoices and credit notes in UBL 2.1 and UN/CEFACT CII D16B. Framework-agnostic and MIT licensed.
Source code on GitHub under the MIT license.
The gap
An EN 16931 invoice has to be correct XML in UBL 2.1 or CII, and it also has to follow the business rules of the standard. Checking both from a PHP application usually means calling out to separate tools.
What it is
PN Scripts Invoice builds the invoice or credit note in PHP, writes it as UBL 2.1 or CII D16B, and validates it in layers: XML safety, XSD against the bundled official schemas, then 104 EN 16931 business rules in pure PHP.
How you use it
Add it with composer require pnscripts/pn-invoice, or check an existing file with bin/pn-invoice validate.
A technical tool for developers. It checks a documented subset of the EN 16931 business rules, not full conformance, and it is not legal or tax advice.
Use it when
Built for
Build an invoice or credit note once and write it as UBL 2.1 or UN/CEFACT CII D16B.
Input is parsed with network access off, and a document with a DOCTYPE is refused.
Documents are checked against the official XSD schemas that ship with the package.
A documented subset of the EN 16931 business rules runs in pure PHP. It is not full conformance with the standard.
An optional adapter runs Schematron validation through Saxon.
bin/pn-invoice validate checks a file from the terminal.
v0.1.0 is the first release. Everything under Planned is not in it yet.
| Platform or runtime | Supported versions | Tested up to |
|---|---|---|
| PHP | 8.3 or newer | 8.5 |
Install it with composer require pnscripts/pn-invoice, or clone the public repository. Free under MIT.
Source code on GitHub under the MIT license.