gbxnga / laravel-ledger
General Ledger and Journal Accounting Package for Laravel with JSON API
Installs: 54
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 29
pkg:composer/gbxnga/laravel-ledger
Requires
- php: ^8.2
- ext-bcmath: *
- ext-json: *
- ext-pdo: *
- abivia/hydration: ^2.5
Requires (Dev)
- ext-pdo_sqlite: *
- orchestra/testbench: ^9.0|^10.0
- phpunit/phpunit: ^11.0
Replaces
- abivia/ledger: v2.1.1
README
General Ledger and Journal Accounting Package for Laravel with JSON API.
A maintained fork of abivia/ledger, upgraded to support modern PHP and Laravel versions.
Features
- Full double-entry accounting system with audit trail capability.
- Multi-currency support.
- Support for multiple business units.
- Sub-journal support.
- Multilingual.
- Integrates via direct controller access or through JSON API.
- Atomic transactions with concurrent update blocking.
- Reference system supports soft linking to other ERP components.
- Bulk journal detail inserts and aggregated balance updates for high-volume posting.
- Automatic batch coalescing — consecutive
entry/addandentry/deleteoperations in a batch are merged into bulk passes. - Configurable chunk sizes and optional performance metrics logging.
Requirements
- PHP 8.2+
- Laravel 11 or 12
Installation
composer require gbxnga/laravel-ledger
Publish configuration:
php artisan vendor:publish --provider="Abivia\Ledger\LedgerServiceProvider"
Create database tables:
php artisan migrate
Migrating from abivia/ledger
If you're currently using abivia/ledger, you can switch to this package with minimal effort. All PHP namespaces (Abivia\Ledger\*) remain unchanged, so your application code works as-is.
- Swap the package:
composer remove abivia/ledger composer require gbxnga/laravel-ledger
- Update your PHP and Laravel versions if needed:
- PHP 8.2+ (previously 8.0+)
- Laravel 11 or 12 (previously Laravel 8+)
Your published config (config/ledger.php), migrations, and database tables are not affected by the package swap. No changes are needed to your service provider references, config files, migrations, or any code that uses Abivia\Ledger classes.
Configuration
The configuration file is installed as config/ledger.php. You can enable/disable the JSON API, set middleware, and a path prefix to the API.
Performance Tuning
Journal detail inserts and balance updates are performed in bulk using chunked queries. When a batch contains consecutive entry/add or entry/delete operations, they are automatically coalesced into grouped passes — reducing database round-trips from O(n) per detail line to O(1) chunked operations.
All settings live under ledger.performance in config/ledger.php and can be overridden via environment variables:
| Environment Variable | Default | Description |
|---|---|---|
LEDGER_ENTRY_DETAIL_CHUNK |
1000 |
Max rows per journal_details bulk insert |
LEDGER_ENTRY_BALANCE_CHUNK |
500 |
Max rows per ledger_balances select/upsert pass |
LEDGER_ROOT_DETAIL_CHUNK |
1000 |
Max rows per opening-balance detail insert |
LEDGER_ROOT_BALANCE_CHUNK |
500 |
Max rows per opening-balance upsert |
LEDGER_BATCH_COALESCE_ENTRY_ADD |
true |
Merge consecutive entry/add batch operations into one bulk write |
LEDGER_BATCH_COALESCE_ENTRY_DELETE |
true |
Merge consecutive entry/delete batch operations into one bulk delete/reversal pass |
LEDGER_BATCH_COALESCE_MIN_GROUP |
2 |
Minimum consecutive add/delete operations required before coalescing activates |
LEDGER_PERFORMANCE_METRICS |
false |
Emit structured performance logs (detail rows, chunks, elapsed time) |
Updating
To ensure schema changes are in place, publish the configuration again and migrate:
php artisan vendor:publish --provider="Abivia\Ledger\LedgerServiceProvider"
php artisan migrate
Testing
composer test
With coverage:
composer test-coverage
Documentation
Full documentation is available at ledger.abivia.com.
Credits
- Alan Langford - Original author
- Gbenga Oni - Maintainer of this fork
License
MIT. See LICENSE for details.