Ledga

PHP SDK

Official client for PHP 8.2+. Wraps every account, transaction, trancode, journal, set and report endpoint.

Install

composer require ledga/ledga-php

Pre-1.0: the API may change between minor versions. Source: github.com/ledga/ledga-php.

Configure

use Ledga\Api\LedgaClient;

$ledga = new LedgaClient('sk_xxxxxxxx_your_secret');

// Self-hosted or local
$ledga = new LedgaClient(apiKey: 'sk_…', baseUrl: 'http://localhost:15080', timeout: 60);
Parameter Default
apiKey required
baseUrl https://ledga.io
timeout 30 seconds

Services

Property Methods
$ledga->accounts list, all, get, create, update, delete, getBalance, getByCode, getBalanceByCode, getBalanceHistory, getEntries, initializeDefaults
$ledga->transactions list, all, get, create, createFromCode, reverse, createBatch
$ledga->transactionCodes list, all, get, create, update, deprecate, validateParams
$ledga->journals list, all, get, create, update, delete
$ledga->accountSets list, all, get, create, update, delete, addMember, removeMember, getAccounts, getBalance
$ledga->reports trialBalance, incomeStatement

Strings, FX and attribute-catalog endpoints are not wrapped yet; call them over HTTP.

Responses

The SDK strips the envelope: methods return typed resources (Account, Transaction, TransactionAcknowledgement, …) with camelCase properties. list() returns a PaginatedResponse (data, hasMore(), nextPage(), previousPage()); all() returns a lazy iterator over every page. Enums (AccountType, TransactionStatus, TransactionLayer, …) are backed PHP enums — compare with cases, not strings.

Errors

Every API error becomes a LedgaException subclass; see the error table. LedgaValidationException::getErrors() returns the per-field messages; LedgaRateLimitException::getRetryAfter() the wait in seconds.