Download the PHP package xmlvalid/xmlvalid-php without Composer
On this page you can find all versions of the php package xmlvalid/xmlvalid-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download xmlvalid/xmlvalid-php
More information about xmlvalid/xmlvalid-php
Files in xmlvalid/xmlvalid-php
Package xmlvalid-php
Short Description PHP client for the xmlvalid API: validate XML and e-invoices (Peppol, XRechnung, Factur-X, UBL, CII) against XSD, DTD, RelaxNG and Schematron business rules
License MIT
Homepage https://xmlvalid.com/docs/api
Informations about the package xmlvalid-php
xmlvalid for PHP
PHP client for the xmlvalid API: validate XML documents and e-invoices against XSD, DTD, RelaxNG and Schematron business rules. Peppol BIS, XRechnung, Factur-X / ZUGFeRD, EN 16931, UBL, CII and national rules (France, Italy, Croatia, Romania and more) are in the schema catalog; your own schemas work too.
- PHP 8.2+, any PSR-18 HTTP client (Guzzle, Symfony HttpClient, …)
- Files are streamed, never loaded into memory
- Waits for the result for you, retries when rate limited
- Typed results and exceptions, webhook signature checks
Install
If your project has no PSR-18 client yet, Composer adds one for you (php-http/discovery). Create an API key under Dashboard → API keys.
Validate
The document can be:
The schema:
| Argument | Validates against |
|---|---|
schema: 'peppol-bis-3-invoice' |
A catalog entry, with its business rules |
schema: 'auto' |
The catalog profile an e-invoice names (BT-24), for mixed invoices |
schema: '@orders-v3' |
One of your saved schemas |
schemaFile: 'order.xsd' |
An XSD, DTD or RelaxNG file sent with the document |
doctype: true |
The DOCTYPE the document declares |
| none | Well-formedness only |
Your own Schematron runs after the schema check: rules: 'rules.sch', or for rules with
includes, relative path => file: rules: ['main.sch' => '/path/main.sch', 'parts/totals.sch' => '/path/parts/totals.sch'].
A catalog schema's business rules move to new releases (Peppol BIS, XRechnung). To fail
instead of getting findings from rules that changed, pin the releases a check was written
against: rulesVersion: '[email protected]' (or a list). If one runs another release,
RulesVersionMismatchException is thrown before anything runs or counts. schemas() lists
each schema's ruleSets with their current releases.
The result
For a .zip, $validation->result->items has one result per document; for a PDF,
$validation->result->pdf names the invoice found in it.
Write e-invoices from JSON
createInvoice() writes an invoice as XRechnung (UBL or CII), Peppol BIS, ZUGFeRD / Factur-X or a
French CTC invoice, with the e-invoice generator's code, and checks it against the profile's
schema and business rules. format: 'pdf' makes a ZUGFeRD PDF with the XML inside.
The fields are listed in the API reference.
Long validations, reports and the account
validate() waits up to 15 minutes (timeout:); a TimeoutException carries the validation,
which goes on on the server. To queue and come back later:
Errors
Every exception extends Xmlvalid\Exception\XmlvalidException. API refusals are
ApiExceptions with $statusCode, $errorCode and, for invalid_request, $fields:
| Exception | When |
|---|---|
AuthenticationException |
401: no key, a revoked key |
PlanLimitException |
403: not in your plan |
NotFoundException |
404: no such validation, or it expired (24 hours) |
NotFinishedException |
409: the report of a validation still running |
RulesVersionMismatchException |
409: a rule set pinned with rulesVersion runs another release; $ruleSet, $pinned, $current |
DocumentTooLargeException |
413: over your plan's size limit |
InvalidRequestException |
422: unknown schema, a bad URL, … |
QuotaExceededException |
429: this month's validations are used up |
RateLimitedException |
429: still limited after the retries; $retryAfter seconds |
ServerException |
5xx |
TransportException |
The request could not be sent or its answer read |
TimeoutException |
Still running after timeout: |
Webhooks
On Pro, xmlvalid can call your endpoint when a validation finishes or a URL monitor changes state. Check the signature with the endpoint's secret and the raw body:
Options
Development
License
MIT
All versions of xmlvalid-php with dependencies
ext-json Version *
php-http/discovery Version ^1.19
psr/http-client Version ^1.0
psr/http-client-implementation Version *
psr/http-factory Version ^1.0
psr/http-factory-implementation Version *
psr/http-message Version ^1.1 || ^2.0