Search by

silarhi / cfonb-parser

guillaume-sainthillier

A PHP parser for CFONB 120 and 240 bank files (statements and transfers), with zero dependencies

Package info

github.com/silarhi/cfonb-parser

pkg:composer/silarhi/cfonb-parser

Statistics

Installs: 60 398

Dependents: 0

Suggesters: 1

Stars: 10

Open Issues: 2

6.5.0 2026-10-13 13:41 UTC

README

Latest Stable Version Total Downloads License PHP Version CI Status Coverage

CFONB Parser

Parse French CFONB 120 and 240 bank files into typed PHP objects.
Bank statements and transfers, with zero runtime dependencies.

📖 Documentation

Features

  • Zero dependencies — only PHP is required, nothing else gets pulled into your project.
  • CFONB 120 statements — Statement objects with opening/closing balances (01/07), operations (04) and their details (05).
  • CFONB 240 transfers — Transfer objects with a header (31), transactions (34) and a total (39).
  • Signed amounts — CFONB 120 decimals and sign characters are decoded: credits are positive, debits are negative.
  • Typed value objects — getters return floats, dates (DateTimeImmutable for CFONB 120, typed DateTimeInterface for CFONB 240) and nullable strings, not raw arrays.
  • Tolerant input — handles \n, \r\n and \r (since 6.5) line endings, and files with no line breaks at all.
  • Strict parsing — malformed lines and, since 6.5, records out of order and zero-filled dates throw a ParseException instead of producing silent garbage, whatever the mode: non-strict mode only accepts blank CFONB 120 operation references.

Requirements

  • PHP 8.2+

Installation

composer require silarhi/cfonb-parser

Quick start

use Silarhi\Cfonb\Cfonb120Reader;

$reader = new Cfonb120Reader();

foreach ($reader->parse(file_get_contents('statements.txt')) as $statement) {
    echo sprintf("Opening balance: %.2f\n", $statement->getOldBalance()->getAmount());

    foreach ($statement->getOperations() as $operation) {
        echo sprintf("%s %s %.2f\n", $operation->getDate()->format('Y-m-d'), $operation->getLabel(), $operation->getAmount());
    }

    echo sprintf("Closing balance: %.2f\n", $statement->getNewBalance()->getAmount());
}

CFONB 240 transfers are read the same way with Cfonb240Reader, both formats with CfonbReader.

Documentation

Everything else is on cfonb-parser.silarhi.dev:

Contributing

See CONTRIBUTING.md.

License

MIT License. See LICENSE for details.

Built with care by SILARHI.
If CFONB Parser saves you time, consider giving it a star on GitHub.