PHPackages                             php-finance/double-entry - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. php-finance/double-entry

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

php-finance/double-entry
========================

Double entry accounting

22123PHPCI passing

Since Feb 20Pushed 1y ago4 watchersCompare

[ Source](https://github.com/php-finance/double-entry)[ Packagist](https://packagist.org/packages/php-finance/double-entry)[ RSS](/packages/php-finance-double-entry/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

PHP Finance - Double Entry
==========================

[](#php-finance---double-entry)

[![Latest Stable Version](https://camo.githubusercontent.com/a4da4261777cdbc58409ac6a4459ee2e21a94c2c73f084db0d1ec4241b16e1fa/68747470733a2f2f706f7365722e707567782e6f72672f7068702d66696e616e63652f646f75626c652d656e7472792f76)](https://packagist.org/packages/php-finance/double-entry)[![Total Downloads](https://camo.githubusercontent.com/5a564bac681e13224c30f6de8b6be59a0002e16357e1b1cc7da88204527dc930/68747470733a2f2f706f7365722e707567782e6f72672f7068702d66696e616e63652f646f75626c652d656e7472792f646f776e6c6f616473)](https://packagist.org/packages/php-finance/double-entry)[![Build status](https://github.com/php-finance/double-entry/actions/workflows/build.yml/badge.svg)](https://github.com/php-finance/double-entry/actions/workflows/build.yml)[![Coverage Status](https://camo.githubusercontent.com/1c2ecbe079fc2a6b562ad6c38fee673812fd18366ce2abba9f84271177d53dff/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f7068702d66696e616e63652f646f75626c652d656e7472792f62616467652e737667)](https://coveralls.io/github/php-finance/double-entry)[![Mutation testing badge](https://camo.githubusercontent.com/892f1392340c0a6743a6373fe245efbf8936fb30be5d70d990583525d646f0d8/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d2532467068702d66696e616e6365253246646f75626c652d656e7472792532466d6173746572)](https://dashboard.stryker-mutator.io/reports/github.com/php-finance/double-entry/master)[![type-coverage](https://camo.githubusercontent.com/28e4c1332cd098203bca480388ff9f51d18f64c20f45580d5b33fec38e4e8541/68747470733a2f2f73686570686572642e6465762f6769746875622f7068702d66696e616e63652f646f75626c652d656e7472792f636f7665726167652e737667)](https://shepherd.dev/github/php-finance/double-entry)[![static analysis](https://github.com/php-finance/double-entry/workflows/static%20analysis/badge.svg)](https://github.com/php-finance/double-entry/actions?query=workflow%3A%22static+analysis%22)[![psalm-level](https://camo.githubusercontent.com/80339a5ad4506945e620ba35a8da6cc6eee5d17855dc201fbaf8e03782280fd7/68747470733a2f2f73686570686572642e6465762f6769746875622f7068702d66696e616e63652f646f75626c652d656e7472792f6c6576656c2e737667)](https://shepherd.dev/github/php-finance/double-entry)

[Double entry](https://en.wikipedia.org/wiki/Double-entry_bookkeeping) is an awesome proven approach to financial and analytical accounting. It allows doing accounting of any complexity.

The library features are:

- Generic double entry accounting implementation.
- Multiple data storage backends available as separate packages.
- Transactional.
- Supports sub-accounts and dimensions.
- Avoids precision problems.
- Documentation and examples.

Glossary
--------

[](#glossary)

A short glossary is necessary for understanding what's going on.

- **Asset** is something of value the company owns.
- **Liability** is something that company owes to another company, bank or person.
- **Debit** is an accounting entry that results in either increase of assets or decrease in liabilities.
- **Credit** is an accounting entry that results in either decrease of assets or increase in liabilities.
- **Entry** is a debit or a credit entry for a certain account.
- **Posting** is a balanced pair of debit and credit entries that reflects moving of assets or liabilities between accounts.
- **Transaction** is a financial operation that includes one or several postings.
- **Account** is group of entries connected to a certain asset or liability.
- **Subaccount** is used to further specify the purpose of the entries within the account.
- **Dimension** is used to tag entries regardless of the account.
- **Total debit** is a sum of all debit of the account.
- **Total credit** is a sum of all credit of the account.
- **Balance** is an account remainder.
- **Chart of accounts (COA)** is a system of accounts, subaccounts, and dimensions, that allows accounting with the ability to calculate metrics needed.

Example
-------

[](#example)

Let's assume we want to do accounting for an ice cream company. It has three trucks, each truck has a driver who's the cashier at the same time. Also they have two storages with one worker in each. Company took out a loan to buy the trucks. Ice-cream is bought from two factories.

The founder wants an accounting to answer the following questions:

1. What's the sales revenue? What's the sales revenue for each truck?
2. What's the net profit margin?
3. What's the equity of the company?
4. What are expenses? How much was spent on salaries, buying ice-cream, trucks and gasoline, storages? How much was paid to each worker / storage / truck / factory?

In terms of accounting that means the following answers:

- Q: How much funds does the company have?
- A: Balance of subaccounts of "Company funds"
- Q: How much we spend?
- A: Total credit of subaccounts of "Company funds"
- Q: How much is spent on buying ice cream?
- A: Total debit of account "Purchases"
- Q: How much is paid to each factory?
- A: Total debit of account "Purchases" grouped by dimension "Counterparty"
- Q: How much is spent on salaries?
- A: Total debit of account "Expenses → Salary"
- Q: How much is spent on salaries of each employee?
- A: Total debit of account "Expenses → Salary" grouped by dimension "Employee"
- Q: How much is spent on truck fuel?
- A: Total debit of account "Expenses → Fuel"
- Q: How much is spent on truck fuel for each truck?
- A: Total debit of account "Expenses → Fuel" grouped by dimension "Truck"
- A: What are total sales revenue?
- Q: Total credit of account "Revenue"
- Q: What are total sales revenue for each truck?
- A: Total debit of "Company funds → Truck" grouped by dimension "Income type"

And that would be the following chart of accounts:

// TODO: add it as a table

Let's add it:

```
// TODO: add it
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance33

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity15

Early-stage or recently created project

 Bus Factor1

Top contributor holds 76.5% of commits — single point of failure

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.

### Community

Maintainers

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

![](https://www.gravatar.com/avatar/53e5ee1dedd50f71e4aeeac2929f786cdfb400359d4776e6cd806388d0d5df2c?d=identicon)[vjik](/maintainers/vjik)

---

Top Contributors

[![vjik](https://avatars.githubusercontent.com/u/525501?v=4)](https://github.com/vjik "vjik (13 commits)")[![samdark](https://avatars.githubusercontent.com/u/47294?v=4)](https://github.com/samdark "samdark (3 commits)")[![rustamwin](https://avatars.githubusercontent.com/u/16498265?v=4)](https://github.com/rustamwin "rustamwin (1 commits)")

### Embed Badge

![Health badge](/badges/php-finance-double-entry/health.svg)

```
[![Health](https://phpackages.com/badges/php-finance-double-entry/health.svg)](https://phpackages.com/packages/php-finance-double-entry)
```

###  Alternatives

[php-flasher/flasher

The foundational PHP library for PHPFlasher, enabling the creation of framework-agnostic flash notifications. Ideal for building custom integrations or for use in PHP projects.

634.6M32](/packages/php-flasher-flasher)[verbb/redactor-tweaks

Provide some tweaks for Redactor.

1791.6k](/packages/verbb-redactor-tweaks)

PHPackages © 2026

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