Skip to content

PHP Twinfield SDK

A modern, strictly typed PHP SDK for the Twinfield accounting API. OAuth2 login, a fluent Finder and PSR interfaces all the way down.
Terminal window
composer require solvebeam/twinfield
use SolveBeam\Twinfield\Finder\FinderType;
use SolveBeam\Twinfield\Twinfield;
$twinfield = Twinfield::create($accessTokenProvider)->company('1000');
foreach ($twinfield->offices()->list() as $office) {
echo $office->code, ' ', $office->name, PHP_EOL;
}
$debtors = $twinfield->finder(FinderType::Dimensions)
->option('dimtype', 'DEB')
->limit(10)
->get();

OAuth2 built in

Log in once, store the refresh token, and access tokens are refreshed and cached for you. The cluster URL of the organisation is found automatically.

Fluent Finder

Search dimensions, countries and more with options, limits and lazy pagination: all() fetches the next page only when your loop needs it.

PSR all the way

Bring your own PSR-18 HTTP client, PSR-17 factories, PSR-6 cache and PSR-3 logger. Nothing is hard-wired.

Strict models

Read models are typed and validated. Unexpected responses throw instead of quietly turning into empty values.