Install and use the official econnect-psb-php SDK: Composer, authentication, sending invoices and webhook examples.
The PHP SDK (econnect-psb-php) is a reference implementation for the PSB REST API. The library handles OAuth token management and provides typed API classes for common operations.
curl, json, mbstringcomposer require everbinding/econnect-psb-php
Then load the Composer autoloader in your project:
require __DIR__ . '/vendor/autoload.php';
Set the default configuration with your credentials and the correct environment. During development, use the acceptance URLs.
$config = \EConnect\Psb\Configuration::getDefaultConfiguration();
$config
->setUsername('your-username') // only for Resource Owner flow
->setPassword('your-password') // only for Resource Owner flow
->setClientId('your-client-id')
->setClientSecret('your-client-secret')
->setHost('https://accp-psb.econnect.eu')
->setApiKey('Subscription-Key', 'your-subscription-key'); // optional, legacy
For the Identity Server, the SDK uses OpenID Connect internally via jumbojett/openid-connect-php. Which credentials you need depends on the chosen OAuth2 flow — see Authentication.
setHost)https://accp-psb.econnect.euhttps://accp-identity.econnect.euhttps://psb.econnect.euhttps://identity.econnect.euTip: the
Subscription-Keyis legacy for the PSB API and is no longer required. If you send it, the value must still be valid.
After configuration, call login() to obtain and cache an access token:
$config = \EConnect\Psb\Configuration::getDefaultConfiguration();
$auth = new \EConnect\Psb\Authentication($config);
$auth->login();
The SDK refreshes the token automatically as long as you reuse the same Configuration instance.
With SalesInvoiceApi you send a UBL file to the PSB. The {partyId} is the sender's Peppol identifier; the receiver is optional — the PSB then picks the best route.
$config = \EConnect\Psb\Configuration::getDefaultConfiguration();
$salesInvoiceApi = new \EConnect\Psb\Api\SalesInvoiceApi(
new GuzzleHttp\Client(),
$config
);
$senderPartyId = '0106:12345678';
$filePath = './invoice.xml';
$receiverPartyId = null; // optional
$salesInvoiceApi->sendSalesInvoice($senderPartyId, $filePath, $receiverPartyId);
Make sure the UBL document is valid; otherwise the PSB blocks the send. More about the endpoint and idempotency: Send invoice.
The repository includes examples for receiving incoming invoices via webhooks:
ExampleWebhookReceiver.php — webhook endpointExampleSendInvoice.php — send via PeppolPSB webhooks are secured with an X-EConnect-Signature header. See Configure webhooks for platform configuration.
The SDK generates API classes per endpoint group from the OpenAPI spec. You can find the full list in the repository and on psb.econnect.eu. Typical classes:
SalesInvoiceApiPurchaseInvoiceApiHookApiPeppolApiConsult the Swagger UI for request and response schemas per operation.
The SDK uses Guzzle as the HTTP client. API errors (4xx, 5xx) surface as GuzzleHttp\Exception\ClientException or ServerException. Check $e->getResponse()->getBody() for the PSB error details.
401 Unauthorizedlogin() again400 Bad Request409 Conflict5xxInstead of this library, you can also generate PHP code from the OpenAPI spec. See OpenAPI codegen for the command and authentication notes.
The repository describes itself as a reference implementation. The code is open source and used in practice, but always verify that the Packagist version matches your PHP version and that the endpoints you need are covered. For full API coverage you can also run codegen yourself.
The package requires PHP 7.2+. The latest release on Packagist is v0.9.2 (August 2021). Test your integration thoroughly in the acceptance environment.