PHPackages                             code050/twinfield - 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. code050/twinfield

Abandoned → [php-twinfield / twinfield](/?search=php-twinfield%20%2F%20twinfield)Library[API Development](/categories/api)

code050/twinfield
=================

Library for using the Twinfield Soap Service.

v2.9.0(6y ago)052GPL-3.0-or-laterPHPPHP &gt;=7.1CI failing

Since Mar 27Pushed 5y agoCompare

[ Source](https://github.com/code050/twinfield)[ Packagist](https://packagist.org/packages/code050/twinfield)[ Docs](https://github.com/php-twinfield/twinfield)[ RSS](/packages/code050-twinfield/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (8)Dependencies (10)Versions (39)Used By (0)

Twinfield [![Build Status](https://camo.githubusercontent.com/56c853582c7937b010e17906011e3a029457d4d38af1a6ec3069a4b5c5bdb19b/68747470733a2f2f7472617669732d63692e6f72672f7068702d7477696e6669656c642f7477696e6669656c642e7376673f6272616e63683d6d6173746572)](http://travis-ci.org/php-twinfield/twinfield)
=============================================================================================================================================================================================================================================================================================================

[](#twinfield--)

A PHP library for Twinfield Integration. Use the Twinfield SOAP Service to have your PHP application communicate directly with your Twinfield account.

> ⚠️ This library is still under construction. [Version 1](https://github.com/php-twinfield/twinfield/tree/release-1.0) is available from Composer, but we recommend you to wait for (or help with!) version 2. We hope to release it early 2018.

---

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

[](#installation)

Install this Twinfield PHP library with Composer:

```
composer require code050/twinfield
```

Usage
-----

[](#usage)

### Authentication

[](#authentication)

You need to set up a `\PhpTwinfield\Secure\AuthenticatedConnection` class with your credentials. When using basic username and password authentication, the `\PhpTwinfield\Secure\WebservicesAuthentication` class should be used, as follows:

```
$connection = new Secure\WebservicesAuthentication("username", "password", "organization");
```

In order to use OAuth2 to authenticate with Twinfield, one should use the `\PhpTwinfield\Secure\Provider\OAuthProvider` to retrieve an `\League\OAuth2\Client\Token\AccessToken` object. Next to the `OAuthProvider` and `AccessToken`, it is required to set up a default `\PhpTwinfield\Office`, that will be used during requests to Twinfield. **Please note:** when a different office is specified when sending a request through one of the `ApiConnectors`, this Office will override the default.

Using this information, we can create an instance of the `\PhpTwinfield\Secure\OpenIdConnectAuthentication` class, as follows:

```
$provider    = new OAuthProvider([
    'clientId'     => 'someClientId',
    'clientSecret' => 'someClientSecret',
    'redirectUri'  => 'https://example.org/'
]);
$accessToken = $provider->getAccessToken("authorization_code", ["code" => ...]);
$office      = \PhpTwinfield\Office::fromCode("someOfficeCode");

$connection  = new \PhpTwinfield\Secure\OpenIdConnectAuthentication($provider, $accessToken, $office);
```

For more information about retrieving the initial `AccessToken`, please refer to:

### Getting data from the API

[](#getting-data-from-the-api)

In order to communicate with the Twinfield API, you need to create an `ApiConnector` instance for the corresponding resource and use the `get()` or `list()` method.

The `ApiConnector` takes a `Secure\AuthenticatedConnection` object:

An example:

```
$connection = new Secure\AuthenticatedConnection("username", "password", "organization");
$customerApiConnector = new ApiConnectors\CustomerApiConnector($connection);

// Get one customer.
$office   = Office::fromCode('office code');
$customer = $customerApiConnector->get('1001', $office);

// Get a list of all customers.
$customer = $customerApiConnector->listAll($office);
```

### Creating or updating objects

[](#creating-or-updating-objects)

If you want to create or update a customer or any other object, it's just as easy:

```
$customer_factory = new ApiConnectors\CustomerApiConnector($connection);

// First, create the objects you want to send.
$customer = new Customer();
$customer
    ->setCode('1001')
    ->setName('John Doe')
    ->setOffice($office)
    ->setEBilling(false);

$customer_address = new CustomerAddress();
$customer_address
    ->setType('invoice')
    ->setDefault(false)
    ->setPostcode('1212 AB')
    ->setCity('TestCity')
    ->setCountry('NL')
    ->setTelephone('010-12345')
    ->setFax('010-1234')
    ->setEmail('johndoe@example.com');
$customer->addAddress($customer_address);

// And secondly, send it to Twinfield.
$customer_factory->send($customer);
```

You can also send multiple objects in one batch, chunking is handled automatically.

### Supported resources

[](#supported-resources)

Not all resources from the Twinfield API are currently implemented. Feel free to create a pull request when you need support for another resource.

Componentget()listAll()send()Mapper[Articles](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Articles)✅✅✅[BankTransaction](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankTransactions)✅[Customer](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Customers)✅✅✅✅[Electronic Bank Statements](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/BankStatements)✅[Sales Invoices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesInvoices)✅✅✅[Matching](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Miscellaneous/Matching)✅[Offices](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Offices)✅[Suppliers](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Suppliers)✅✅✅✅Transactions:
 [Purchase](https://c3.twinfield.com/webservices/documentation/#/ApiReference/PurchaseTransactions), [Sale](https://c3.twinfield.com/webservices/documentation/#/ApiReference/SalesTransactions), [Journal](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Transactions/JournalTransactions)✅✅✅[Users](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/Users)✅[Vat types](https://c3.twinfield.com/webservices/documentation/#/ApiReference/Masters/VAT)✅Links
-----

[](#links)

- [Twinfield API Documentation site](https://c3.twinfield.com/webservices/documentation/)

Authors
-------

[](#authors)

- [Pronamic](https://www.pronamic.nl/)
- [Mollie](https://www.mollie.com/)
- [Remco Tolsma](https://www.remcotolsma.nl/)
- [Emile Bons](http://www.emilebons.nl/)
- [Alex Jeensma](http://vontis.nl/)

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor3

3 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~88 days

Recently: every ~0 days

Total

34

Last Release

1886d ago

Major Versions

0.0.1 → v1.0.02017-11-15

v1.1.0 → v2.0.02018-02-12

PHP version history (4 changes)0.0.1PHP &gt;=5.4

v1.0.0PHP &gt;=5.6

v1.1.0PHP &gt;=5.3

v2.0.0PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/bb78fcc4960bbdebb8948afb6a2c594ec69357f0f182a82b21d16d7e6b44fbed?d=identicon)[Code050](/maintainers/Code050)

---

Top Contributors

[![zogot](https://avatars.githubusercontent.com/u/493614?v=4)](https://github.com/zogot "zogot (131 commits)")[![remcotolsma](https://avatars.githubusercontent.com/u/869674?v=4)](https://github.com/remcotolsma "remcotolsma (62 commits)")[![Thijs-Riezebeek](https://avatars.githubusercontent.com/u/14027813?v=4)](https://github.com/Thijs-Riezebeek "Thijs-Riezebeek (34 commits)")[![maikel-mollie](https://avatars.githubusercontent.com/u/263946459?v=4)](https://github.com/maikel-mollie "maikel-mollie (24 commits)")[![NoDiscipline](https://avatars.githubusercontent.com/u/5564740?v=4)](https://github.com/NoDiscipline "NoDiscipline (16 commits)")[![alexjeen](https://avatars.githubusercontent.com/u/1567497?v=4)](https://github.com/alexjeen "alexjeen (13 commits)")[![manuelderuiter](https://avatars.githubusercontent.com/u/329788?v=4)](https://github.com/manuelderuiter "manuelderuiter (11 commits)")[![willemstuursma](https://avatars.githubusercontent.com/u/701299?v=4)](https://github.com/willemstuursma "willemstuursma (9 commits)")[![RickJeroen](https://avatars.githubusercontent.com/u/15357844?v=4)](https://github.com/RickJeroen "RickJeroen (9 commits)")[![Wouter0100](https://avatars.githubusercontent.com/u/864520?v=4)](https://github.com/Wouter0100 "Wouter0100 (8 commits)")[![Versleijen](https://avatars.githubusercontent.com/u/17478164?v=4)](https://github.com/Versleijen "Versleijen (8 commits)")[![EmileBons](https://avatars.githubusercontent.com/u/3186640?v=4)](https://github.com/EmileBons "EmileBons (7 commits)")[![axlon](https://avatars.githubusercontent.com/u/3661474?v=4)](https://github.com/axlon "axlon (7 commits)")[![arnoutdemooij](https://avatars.githubusercontent.com/u/929767?v=4)](https://github.com/arnoutdemooij "arnoutdemooij (6 commits)")[![stephangroen](https://avatars.githubusercontent.com/u/1607643?v=4)](https://github.com/stephangroen "stephangroen (6 commits)")[![gravytrainhub](https://avatars.githubusercontent.com/u/5164544?v=4)](https://github.com/gravytrainhub "gravytrainhub (6 commits)")[![CasNelissen](https://avatars.githubusercontent.com/u/36226547?v=4)](https://github.com/CasNelissen "CasNelissen (5 commits)")[![vswarte](https://avatars.githubusercontent.com/u/6827387?v=4)](https://github.com/vswarte "vswarte (5 commits)")[![John5](https://avatars.githubusercontent.com/u/1368590?v=4)](https://github.com/John5 "John5 (5 commits)")[![mvdpanne](https://avatars.githubusercontent.com/u/20297716?v=4)](https://github.com/mvdpanne "mvdpanne (5 commits)")

---

Tags

twinfield

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/code050-twinfield/health.svg)

```
[![Health](https://phpackages.com/badges/code050-twinfield/health.svg)](https://phpackages.com/packages/code050-twinfield)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69333.0M114](/packages/algolia-algoliasearch-client-php)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[php-twinfield/twinfield

Library for using the Twinfield Soap Service.

33769.2k1](/packages/php-twinfield-twinfield)[phpro/http-tools

HTTP tools for developing more consistent HTTP implementations.

28137.8k](/packages/phpro-http-tools)[commercetools/commercetools-sdk

The official PHP SDK for the commercetools Composable Commerce APIs

19281.5k](/packages/commercetools-commercetools-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
