krasnyd / eet-client-php
PHP client for Czech EET 2.0 (Elektronická evidence tržeb) SOAP protocol
Requires
- php: ^8.2
- ext-dom: *
- ext-libxml: *
- ext-openssl: *
- guzzlehttp/guzzle: ^7.2 || ^8.0
Requires (Dev)
- phpstan/phpstan: ^2.2
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-08-29 20:35:46 UTC
README
PHP client for the Czech EET 2.0 (Elektronická evidence tržeb) SOAP protocol (schema v4.1).
Builds a signed SOAP message (Trzba), sends it to the EET endpoint, and parses the Odpoved response.
Requirements
- PHP 8.2+
- Extensions:
dom,libxml,openssl - Guzzle 7.2+ / 8.0+
Installation
composer require krasnyd/eet-client-php
Usage
You can find a working playground example in examples/playground.php.
use Krasnyd\Eet\Certificate; use Krasnyd\Eet\ClientOptions; use Krasnyd\Eet\EetClient; use Krasnyd\Eet\Schema\EetSchema; use Krasnyd\Eet\Schema\Trzba; use Krasnyd\Eet\Schema\TrzbaData; use Krasnyd\Eet\Schema\TrzbaHlavicka; $trzba = new Trzba( hlavicka: new TrzbaHlavicka( uuidZpravy: '...', // UUID v4 datOdesl: new DateTimeImmutable('now', new DateTimeZone('Europe/Prague')), prvniZaslani: true, overeni: true, // verification mode – not stored as a sale ), data: new TrzbaData( eicPopl: 'CZ00000019', idJednotky: '1', idPokl: '1', poradCis: '1', datTrzby: new DateTimeImmutable('now', new DateTimeZone('Europe/Prague')), celkTrzba: 100.0, ), ); $certificate = Certificate::fromPkcs12('/path/to/certificate.p12', 'password'); $result = (new EetClient)->submit( $trzba, $certificate, new ClientOptions(endpoint: EetSchema::PLAYGROUND_ADDRESS), ); if (!$result->success()) { echo "Error: " . $result->errorMessage() . "\n"; } echo "POK: " . $result->pok() . "\n";
TrzbaHlavicka / TrzbaData validate values against EET XSD simple types on construction (UUID, EIC, id_jednotky, id_pokl, porad_cis, amounts).
On protocol or transport failure, EetClient::submit() throws Krasnyd\Eet\Exception\EetException. Successful and failed calls expose raw SOAP XML via SubmissionResult / EetException (requestXml, responseXml) for application-level logging or persistence.
Certificates
Playground certificates currently available from the official EET documentation are distributed as legacy PKCS#12 files (using RC2-40-CBC).
On systems using OpenSSL 3.x, PHP may fail to load these files with openssl_pkcs12_read(), because the legacy algorithms used inside the .p12 container are not enabled by default.
If PHP reports the certificate as unreadable even though the password is correct, re-export the certificate into a modern PKCS#12 container using the provided convert-certificates script:
# On Linux / macOS ./convert-certificates.sh <input.p12> [password] [output.p12] # On Windows .\convert-certificates.bat <input.p12> [password] [output.p12]
Playground certificates provided in the resources folder are already converted to modern PKCS#12 containers.
Endpoints
| Environment | Constant / URL |
|---|---|
| Playground | EetSchema::PLAYGROUND_ADDRESS |
| Production | Configure your production URL based on the official documentation |
Testing
composer install
composer test
composer phpstan
License
MIT — see LICENSE.