PHPackages                             setono/economic-php-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. setono/economic-php-sdk

ActiveLibrary[API Development](/categories/api)

setono/economic-php-sdk
=======================

Consume the Economic API with this PHP SDK

v0.2.1(2y ago)01.4kMITPHPPHP &gt;=8.1CI passing

Since May 25Pushed 3w ago1 watchersCompare

[ Source](https://github.com/Setono/economic-php-sdk)[ Packagist](https://packagist.org/packages/setono/economic-php-sdk)[ RSS](/packages/setono-economic-php-sdk/feed)WikiDiscussions 1.x Synced today

READMEChangelog (8)Dependencies (16)Versions (11)Used By (0)

Economic PHP SDK
================

[](#economic-php-sdk)

[![Latest Version](https://camo.githubusercontent.com/bd68164d9a4fdc0029dc19547069e60dd86c8ef9f3a0ac2af2d2b61d2d431e80/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f65636f6e6f6d69632d7068702d73646b2f762f737461626c65)](https://packagist.org/packages/setono/economic-php-sdk)[![Software License](https://camo.githubusercontent.com/a2be2a6186461bfa9d6d1995940573dc3d871f7fb1d386d18a3c7e3d41831951/68747470733a2f2f706f7365722e707567782e6f72672f7365746f6e6f2f65636f6e6f6d69632d7068702d73646b2f6c6963656e7365)](LICENSE)[![Build Status](https://github.com/Setono/economic-php-sdk/workflows/build/badge.svg)](https://github.com/Setono/economic-php-sdk/actions)[![Code Coverage](https://camo.githubusercontent.com/e1836a79195c4f7e1211048f280e33b2eef1f3d80cfcfddee63f0c6a9314b7a6/68747470733a2f2f636f6465636f762e696f2f67682f5365746f6e6f2f65636f6e6f6d69632d7068702d73646b2f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/Setono/economic-php-sdk)[![Mutation testing](https://camo.githubusercontent.com/857c846de00aeeae7d1f50a9a1cba42dd79907d78efc12dfc7c98fa9c6c57f1f/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532465365746f6e6f25324665636f6e6f6d69632d7068702d73646b2532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/Setono/economic-php-sdk/master)

A modern PHP SDK for the [e-conomic REST API](https://restdocs.e-conomic.com/). Typed DTOs for both requests and responses, fully constructor-injected HTTP collaborators (you bring your own PSR-18 client), no surprising magic. Built for PHP 8.4.

**What you get**

- **Typed responses.** `Customer`, `Order`, `Product`, `BookedInvoice`, … come back as concrete DTOs with `public readonly` properties. Your IDE autocompletes; PHPStan at level: max stays happy.
- **Typed write payloads.** `CustomerRequest`, `DraftOrderRequest`, … with constructor-enforced required fields. Optional fields default to `null` and are stripped from the JSON sent to e-conomic — no risk of accidentally sending empty `notes` blocks.
- **`$raw` escape hatch.** Every response DTO carries `public array $raw` with the full decoded JSON, so any field the SDK doesn't type yet is still reachable.
- **Bring your own HTTP client.** PSR-18 + PSR-17 with auto-discovery; inject your own to add retries, logging, or metrics via standard middleware.
- **Honest exceptions.** Server-side validation errors surface as `ValidationException` with e-conomic's nested error document preserved verbatim. 2xx responses that don't fit the SDK's DTO shape surface as `MappingException` with the original Valinor error chained.

Requirements
------------

[](#requirements)

- PHP **8.4** or newer.
- A PSR-18 HTTP client (e.g. `nyholm/psr7` + `symfony/http-client`, `guzzlehttp/guzzle` 7+, …). The SDK uses [`php-http/discovery`](https://github.com/php-http/discovery) to find what you have installed; for production you almost certainly want to inject explicitly (see [Bringing your own HTTP client](#bringing-your-own-http-client)).

Installation
------------

[](#installation)

```
composer require setono/economic-php-sdk
```

If you don't already have a PSR-18 client in your project, install one alongside the SDK:

```
composer require nyholm/psr7 symfony/http-client
```

Quick start
-----------

[](#quick-start)

```
