Download the PHP package pnscripts/pn-invoice without Composer

On this page you can find all versions of the php package pnscripts/pn-invoice. 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 pn-invoice

PN Scripts Invoice

Free, MIT-licensed, framework-agnostic PHP library by PN Scripts to generate and validate EN 16931 e-invoices in both syntaxes allowed by the European standard:

It gives you a small, typed invoice model, writers for both syntaxes, and a layered validator (XML Schema + a documented set of EN 16931 business rules in pure PHP + an optional hook for a full Schematron validator). No framework, no HTTP calls, no floats.

Disclaimer. PN Scripts Invoice is a technical tool. It is not legal or tax advice, and passing its checks does not certify that an invoice is legally compliant. VAT treatment, exemption reasons, numbering and archiving obligations depend on your country and your business; generated invoices must be checked by you or your accountant before they are sent. The PHP business rules cover a subset of EN 16931 (listed below); for full conformance testing use the official Schematron through the adapter.

Requirements

Installation

The official UBL 2.1 and CII D16B XML Schemas are bundled in resources/schemas/ (their licences allow verbatim redistribution, see NOTICE), so XSD validation works offline right after installation.

Quick start

Create an invoice

Amounts are passed as strings or integers and kept as exact decimals (Pnscripts\Invoice\Decimal, backed by bcmath). Totals and the VAT breakdown are always derived from lines and allowances/charges, so the calculation rules BR-CO-10 to BR-CO-17 hold by construction.

Write UBL or CII

A credit note is the same model with kind: DocumentKind::CreditNote (type code 381 by default) and usually a precedingInvoices reference.

Validate

Each Violation has a rule id (BR-CO-10, XSD, XML, ...), a severity (error, warning, info), the layer that produced it, a message, an XPath location and, for XML/XSD errors, a line number. $result->toArray() gives a JSON-ready structure.

Command line

Exit codes: 0 valid, 1 validation errors, 2 usage or input error.

How validation works

Layer What it checks Notes
XML Well-formedness, known root element No network access, DOCTYPE/external entities refused
XSD Official UBL 2.1 / CII D16B schema Structure, element order, data types
Business rules 104 EN 16931 rules in pure PHP (table below) Same results as the official artefacts on their own unit tests
Schematron (optional) Anything your external validator checks You plug it in; see below

Implemented business rules (v0.1)

Group Implemented Not implemented yet
Core (BR-nn) BR-01 to BR-16, BR-21 to BR-33, BR-36 to BR-38, BR-41 to BR-50, BR-55, BR-61, BR-62, BR-63 BR-17 to BR-20 (payee, tax representative), BR-51 to BR-54, BR-56, BR-57, BR-64, BR-65
Conditions and calculations (BR-CO) BR-CO-04, BR-CO-09 to BR-CO-24, BR-CO-26 BR-CO-03; BR-CO-05 to BR-CO-08 (always true in the official artefacts); BR-CO-25 (not in the EN 16931 artefacts 1.3.16)
Standard rated (BR-S) BR-S-01 to BR-S-10
Zero rated (BR-Z) BR-Z-01 to BR-Z-10
Exempt (BR-E) BR-E-01 to BR-E-10
Reverse charge (BR-AE) BR-AE-01 to BR-AE-10
Intra-community (BR-IC / K), export (BR-G), not subject to VAT (BR-O), Canary Islands (BR-IG / L), Ceuta and Melilla (BR-IP / M) none planned
Code lists (BR-CL), decimals (BR-DEC), syntax rules (UBL-CR/SR/DT, CII-SR/DT) none XSD covers structure only

The writers can produce all EN 16931 VAT categories (S, Z, E, AE, K, G, O, L, M); only the rule checks for K, G, O, L and M are missing.

How faithfully are the rules implemented? The rules are written once against a syntax-neutral view of the document and bound to UBL and CII with XPath. Their semantics mirror the official EN 16931 validation artefacts v1.3.16, including their tolerances: BR-CO-17, BR-S-08 and BR-S-09 accept a deviation of less than 1 currency unit, exactly like the official Schematron (the CII binding of BR-CO-17 uses an inclusive bound). The test suite runs all 681 official unit test cases (test/ folder of ConnectingEurope/eInvoicing-EN16931) that name an implemented rule and checks every expected outcome, and validates all 34 official example invoices.

Run vendor/bin/pn-invoice rules for the full list with descriptions.

Full Schematron validation (optional)

The official EN 16931 Schematron, Peppol BIS and XRechnung rules need an XSLT 2.0 processor. PHP's ext-xsl only supports XSLT 1.0, so this library does not run them itself. Instead it offers the SchematronValidator interface and an SVRL parser. A ready-made adapter runs any command that prints SVRL (Schematron Validation Report Language), without a shell:

Saxon and the XSLT files are not shipped; download them from their official sources: Saxon-HE and xmlresolver from Maven Central (net.sf.saxon:Saxon-HE, org.xmlresolver:xmlresolver and its data jar), the artefacts from the EN 16931 releases. You can also implement SchematronValidator yourself (for example to call a validation service).

This exact setup was run on 2026-10-16 (Saxon-HE 12.9, OpenJDK 21, artefacts 1.3.17): every golden file in tests/fixtures/golden/ passes the official Schematron with no errors. tests/Integration/OfficialSchematronTest.php repeats it when PN_INVOICE_SAXON_CP (the class path above) and PN_INVOICE_EN16931_DIR (the unpacked artefacts, with ubl/ and cii/ folders) are set.

Currency codes. The PHP rules do not check code lists (BR-CL). Since artefacts 1.3.17 the official ISO 4217 list no longer contains BGN: Bulgaria has used the euro since 1 January 2026, so invoices in BGN fail BR-CL-03/BR-CL-04 in the official Schematron. Use EUR.

What is not covered (yet)

Development

The official EN 16931 test files in tests/fixtures/official/ are EUPL-1.2 licensed, kept separate with their own NOTICE, and are not part of the Composer package.

Support and more from PN Scripts

Licence

PN Scripts Invoice is released under the NOTICE. "PN Scripts" and "PN Scripts Invoice" are names of ПН СКРИПТС ЕООД and are not covered by the code licence.

Security issues: see SECURITY.md.


All versions of pn-invoice with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
ext-bcmath Version *
ext-dom Version *
ext-libxml Version *
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 pnscripts/pn-invoice contains the following files

Loading the files please wait ...