Search by

cmelda / pohoda

cmelda

Strictly typed PHP client for the STORMWARE POHODA mServer XML API

Package info

gitlab.com/cmelda/pohoda

Issues

pkg:composer/cmelda/pohoda

Fund package maintenance!

Ko-Fi

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

v1.0 2026-10-18 11:51 UTC

This package is auto-updated.

Last update: 2026-10-18 09:55:42 UTC


README

Latest Stable Version Total Downloads License PHP Version Require

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:

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.