Skip to content
PN Scripts

API

PN Scripts Invoice

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.

  • PHP 8.3+
  • ext-dom
  • ext-libxml
  • ext-bcmath
  • UBL 2.1

Get it on

What it solves

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.

Who it is for

Use it when

  • A PHP application that has to issue EN 16931 invoices or credit notes.
  • Checking UBL or CII files before they are processed.

Built for

  • PHP developers on any framework, or none.
  • Teams that build billing or accounting software.

What it does

Two syntaxes, one model

Build an invoice or credit note once and write it as UBL 2.1 or UN/CEFACT CII D16B.

Safe XML first

Input is parsed with network access off, and a document with a DOCTYPE is refused.

Schema validation

Documents are checked against the official XSD schemas that ship with the package.

104 business rules in PHP

A documented subset of the EN 16931 business rules runs in pure PHP. It is not full conformance with the standard.

Schematron when you need it

An optional adapter runs Schematron validation through Saxon.

Command line

bin/pn-invoice validate checks a file from the terminal.

Released, and what comes next

v0.1.0 is the first release. Everything under Planned is not in it yet.

Available now

  • UBL 2.1 and CII D16B invoices and credit notes
  • XML safety, XSD and 104 EN 16931 business rules
  • Optional Schematron adapter for Saxon
  • bin/pn-invoice validate

Planned

  • Sending through Peppol
  • XRechnung
  • Factur-X and ZUGFeRD

Specs

Vendor
PN Scripts
Type
Package
Platforms
PHP
Latest version
v0.2.1
Pricing
Free
License
MIT
Deployment
Composer package
Maturity
v0.2.1, released 2026-10-16
Support
Community

Compatibility

Platform or runtime Supported versions Tested up to
PHP 8.3 or newer 8.5

Releases

  1. v0.2.1

    Release notes (opens in a new tab)
  2. v0.2.0

    Release notes (opens in a new tab)
  3. v0.1.0

    Release notes (opens in a new tab)

Stack

  • PHP 8.3+
  • ext-dom
  • ext-libxml
  • ext-bcmath
  • UBL 2.1
  • UN/CEFACT CII D16B

Get PN Scripts Invoice

Install it with composer require pnscripts/pn-invoice, or clone the public repository. Free under MIT.

Questions

No. It validates against the XSD schemas and checks 104 EN 16931 business rules, a documented subset of the standard. An optional adapter can also run Schematron validation through Saxon.

PHP 8.3 or newer with the dom, libxml and bcmath extensions. It does not depend on a framework. CI runs its 823 tests on PHP 8.3, 8.4 and 8.5.

Not yet. Peppol sending, XRechnung and Factur-X/ZUGFeRD are planned and are not part of v0.1.0.

No. PN Scripts Invoice is a technical tool. Whether an invoice meets the rules that apply to you is for you and your accountant or tax adviser to confirm.