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.

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 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

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

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

PHP Build Version
Package Version
Requires php Version >=8.1
ext-json Version *
ext-curl 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 attestwire/attestwire-php contains the following files

Loading the files please wait ...