cmelda / pohoda
Strictly typed PHP client for the STORMWARE POHODA mServer XML API
Fund package maintenance!
Requires
- php: >=8.4
- ext-dom: *
- ext-iconv: *
- ext-libxml: *
- psr/http-client: ^1.0.3
- psr/http-factory: ^1.1
- psr/http-message: ^2.0
- psr/log: ^3.0
Requires (Dev)
- arxeiss/coding-standards: ^0.14.1
- brick/math: ^1.0
- brick/money: ^0.15.2
- cmelda/pohoda-codeception-adapter: ^1.0
- codeception/codeception: ^5.3.5
- codeception/module-asserts: ^3.3
- guzzlehttp/guzzle: ^8.2
- infection/codeception-adapter: ^0.4.7
- infection/infection: ^0.35.4
- phpstan/phpstan: ^2.2.14
- rector/rector: ^2.6.7
- roave/backward-compatibility-check: ^8.21
Suggests
- ext-curl: Use the built-in cURL transport as the final fallback.
- brick/math: Optional BigDecimal inputs and conversions for exact decimal values.
- brick/money: Optional Money adapters with explicit currency checks; also installs brick/math.
- guzzlehttp/guzzle: Use a PSR-18 client such as Guzzle.
Provides
None
Conflicts
None
Replaces
None
README
Typed PHP 8.4+ client for the STORMWARE POHODA mServer XML API. It builds dataPack requests, communicates with mServer over HTTP, validates requests and responses against 75 bundled official XSD files, and exposes typed request and response DTOs.
What this library is and is not
This library provides the mServer transport, authentication, data-pack envelope, complete XSD DTOs, response parsing, and strict offline XSD validation. Common workflows use factories which hide their XML structure. All bundled schemas also have complete generated DTOs for advanced fields and typed exported records. GenericAgenda and XmlElement are advanced extension points for custom XML.
It is not an abstraction over POHODA's accounting rules. Field availability, required values, permissions, and import behavior remain defined by the POHODA version, accounting unit, user rights, and the relevant STORMWARE XSD. The library catches structural XML errors locally but cannot guarantee that POHODA will accept semantically invalid accounting data.
Installation
Install the stable 1.0 series:
composer require cmelda/pohoda:^1.0
PHP 8.4 and the DOM, libxml, and iconv extensions are required. Install a PSR-18 implementation such as Guzzle, or enable ext-curl for the built-in fallback:
composer require guzzlehttp/guzzle
Quick start
Start with the quick start guide.
use Cmelda\Pohoda\Authentication;
use Cmelda\Pohoda\ClientConfiguration;
use Cmelda\Pohoda\Dto\DataPack;
use Cmelda\Pohoda\Dto\ExportFilter;
use Cmelda\Pohoda\Dto\Schema\ListAddBook\AddressBookExportResult;
use Cmelda\Pohoda\PohodaClient;
$configuration = new ClientConfiguration()
->withBaseUri('http://pohoda.example.test:444');
$client = new PohodaClient(
new Authentication($_ENV['POHODA_USER'], $_ENV['POHODA_PASSWORD']),
$configuration,
);
if (!$client->isAvailable()) {
throw new RuntimeException('POHODA mServer is not available.');
}
$pack = DataPack::forIco('address-export-001', '12345678', 'my-connector')
->withNote('Address book export')
->exportAddressBook(
ExportFilter::byId(42),
100,
);
$response = $client->send($pack);
foreach ($response->items as $item) {
foreach ($item->payloadDtos() as $payload) {
if ($payload instanceof AddressBookExportResult) {
foreach ($payload->addressbook as $record) {
echo ($record->addressbookHeader?->identity?->address->company ?? '') . PHP_EOL;
}
}
}
}
The default endpoints are http://127.0.0.1:444/xml and /status. Authentication uses the mServer-specific STW-Authorization header.
Supported workflows
- named export methods for every list request allowed by the data-pack schema,
- typed invoice, order, activity, and GPSR imports without XML or XSD knowledge (including GPSR updates and deletes),
- complete typed imports for offers, enquiries, bank documents, vouchers, internal documents, warehouse documents, and other supported agendas,
- DTOs for every named declaration in all 75 bundled schemas, plus XML hydration of exported records,
- factories for stock items, address-book entries and centres, common export filters, and supported update/delete actions,
- simple shop export readers for products, contacts, warehouses, categories, orders, invoices, payments, and price levels,
- multiple operations in one
DataPack, with outcome summaries and strict response-ID checks, - sequential batch sending and resume checkpoints,
- accounting-unit selection by company ID (
ico) or key, - request and response validation without network schema access,
- automatic PSR-18/Guzzle or cURL transport selection and custom transports.
Documentation
Prices, quantities, percentages and exchange rates in convenience exports are decimal strings. Exact inputs work without additional dependencies; optional Brick integration supports BigDecimal and currency-checked Money conversions.
Start with simple workflows and complete DTOs, or browse the DTO catalog. See the documentation index for setup, imports, exports, error handling, transports, XSD maintenance, and the public API reference. Runnable examples are available in examples.
For shop integrations, see simple export readers and reading products and stock. send($pack)->products(), customers(), orders(), and invoices() return native snapshots without XML or schema traversal. See version 1.0.0 release notes.
Official references:
- POHODA mServer for developers
- POHODA XML import examples
- POHODA XML export examples
- POHODA XSD schema list
Development
composer install
composer build
composer check
composer mutation
composer check runs Composer validation, unit tests, all XSD bridge checks, reproducible DTO and fixture generation checks, PHPStan at maximum level with bleeding-edge rules, PHPCS, and Rector in dry-run mode.
Unit tests include memory regression scenarios for large orders, batches, XML hydration, product exports and repeated client calls. Run them separately with vendor/bin/codecept run Unit --group memory.
License
MIT. The schemas in resources/schema are provided by STORMWARE; their source, upstream timestamp, and checksum are recorded in resources/schema/VERSION.
For stock-linked shop imports and real mServer round-trip verification, see simple workflows and integration verification. Export snapshots support toArray() and JSON serialization without their schema source.

