Download the PHP package attestwire/attestwire-php without Composer
On this page you can find all versions of the php package attestwire/attestwire-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download attestwire/attestwire-php
More information about attestwire/attestwire-php
Files in attestwire/attestwire-php
Package attestwire-php
Short Description Validate EN 16931 e-invoices (XRechnung, Factur-X/ZUGFeRD, Peppol BIS 3) with the hosted Attestwire API. Includes an adapter for horstoeko/invoicesuite's validator so its users can validate without a Java KoSIT install.
License MIT
Homepage https://attestwire.com
Informations about the package attestwire-php
attestwire/attestwire-php
Validate EN 16931 e-invoices — XRechnung, Factur-X/ZUGFeRD, Peppol BIS 3 —
from PHP, against the hosted Attestwire API. PHP 8.1+, requiring only
ext-json and ext-curl.
validate() takes the document itself — XML bytes/text, a Factur-X/ZUGFeRD
PDF's bytes, or a JSON-encoded InvoiceInput — sniffed from its content
(%PDF, <, {/[), not a file name; there is no separate "read this
file" step. Pass the bytes you already have.
Two packages in one
Attestwire\Client— a thin wrapper aroundPOST https://api.attestwire.com/v1/validate. Use it directly, or as the transport under your own code.Attestwire\InvoiceSuite\AttestwireDocumentValidator— an adapter for horstoeko/invoicesuite, so its users can validate with Attestwire the same way they'd use its built-in KoSIT or DocuFlair validators, with no Java install. See Using it with horstoeko/invoicesuite below.
The result
Errors you handle vs. exceptions you don't expect
A non-compliant invoice is never an exception. validate() returns
normally with $result->valid === false and the findings that explain
why — that's the whole point of the package. What can throw:
| Exception | When |
|---|---|
Attestwire\Exception\ApiException |
The API answered with an HTTP error status: getStatus(), getErrorCode(), getMessage(), getDocsUrl(), getUpgradeUrl() (e.g. 401 invalid_api_key, 413 too_large, 429 rate_limited). |
Attestwire\Exception\AttestwireException |
No API key available anywhere, or the request never reached the API (DNS, connection refused, timeout). Base class of ApiException too, if you want to catch either. |
Configuration
No API key passed to the constructor falls back to the ATTESTWIRE_API_KEY
environment variable; if neither is set, validate() throws
AttestwireException before making any request. Get a free key (no card
required) with POST /v1/keys — see
api.attestwire.com/docs#auth.
Using it with horstoeko/invoicesuite
horstoeko/invoicesuite is an
extensible PHP library for building, reading and validating XRechnung,
ZUGFeRD and Factur-X invoices. Its own validators —
InvoiceSuiteKositDocumentValidator (a Java KoSIT install) and
InvoiceSuiteDocuflairDocumentValidator (the hosted DocuFlair API) — share
one abstract base, InvoiceSuiteAbstractDocumentValidator.
Attestwire\InvoiceSuite\AttestwireDocumentValidator extends that same base,
so it drops in wherever either of those does:
Same createFromFile() / createFromContent() / createFromDocumentReader()
/ createFromDocumentBuilder() factories, same validate() /
getMessageBag() / hasErrorMessagesInMessageBag() /
countWarningMessagesInMessageBag() contract as
InvoiceSuiteDocuflairDocumentValidator — swap one line
(InvoiceSuiteDocuflairDocumentValidator::createFromFile(...)->setApiKey($docuflairKey)
for AttestwireDocumentValidator::createFromFile(...)->setApiKey($attestwireKey))
and everything downstream keeps working.
One deliberate difference, worth knowing about: InvoiceSuiteDocuflairDocumentValidator
only ever adds an ERROR message, and only when its response says the document
is invalid. The Attestwire API always returns three findings arrays —
errors, warnings, information — regardless of valid, and warnings/information
are meaningful even on an invoice that otherwise passes (a missing time of
supply, say). This adapter maps all three every time, to
addErrorMessageToMessageBag() / addWarningMessageToMessageBag() /
addInfoMessageToMessageBag() respectively — so
countWarningMessagesInMessageBag() and countInfoMessagesInMessageBag()
are never silently empty here.
Requirements this adapter has, beyond the base package's: PHP ≥ 8.2
(horstoeko/invoicesuite's own floor) and horstoeko/invoicesuite itself,
which this package does not require — see composer.json's suggest
entry. Install it yourself:
It only validates XML content (matching InvoiceSuiteDocuflairDocumentValidator's
own restriction) — a document built or read through invoicesuite's own
readers/builders, not a raw PDF.
Development
PHP is not installed in the environment this package was written in, and none of the code below has been executed. Treat it as reviewed-but-unverified until it has run once in a real PHP environment.
tests/InvoiceSuite/AttestwireDocumentValidatorTest.php self-skips unless
horstoeko/invoicesuite is also installed:
Every test injects a fake Attestwire\Http\HttpClientInterface
(tests/Fixtures/FakeHttpClient.php / ThrowingHttpClient.php) — nothing
here touches the network or a real curl handle.
A GitHub Actions workflow (.github/workflows/ci.yml) is included for when
this package becomes its own repository; it has likewise never run.
Related
@attestwire/en16931— the rule engine behind the hosted API this package calls.- Attestwire API docs — the full
request/response contract
Clientimplements. - Rule reference — one page per rule, with the reason and the fix.
- horstoeko/invoicesuite — the
library
Attestwire\InvoiceSuite\AttestwireDocumentValidatoradapts to.
License
MIT.
Trademark
"Attestwire"™ and the Attestwire logo are trademarks of this project's owner. The MIT license covers the code and grants no trademark rights. You may say your integration uses this package, or is built on it; you may not name or brand a product or service "Attestwire", or imply that we endorse yours.
All versions of attestwire-php with dependencies
ext-json Version *
ext-curl Version *