Quick start
Parse a QIF file
Section titled “Parse a QIF file”use Silarhi\Qif\Parser;
$parser = Parser::parseFile('/path/to/export.qif');
foreach ($parser->getTransactions() as $transaction) { $transaction->getType(); // ?Types enum, e.g. Types::Bank $transaction->getDate(); // ?DateTimeImmutable $transaction->getAmount(); // ?float, e.g. -1234.5 $transaction->getDescription(); // ?string, the payee (P line) $transaction->getStatus(); // Status enum}To parse content you already have in memory, use the constructor and call parse(), which returns the transactions:
$transactions = (new Parser($content))->parse();Dates are read day first (25/12/2023) and the decimal separator of each amount is detected. For the month-first
dates of US Quicken exports, or to read every amount with the same separator, pass the options:
use Silarhi\Qif\Enums\DateFormat;use Silarhi\Qif\Enums\DecimalSeparator;
$parser = Parser::parseFile('/path/to/export.qif', DateFormat::MonthFirst, DecimalSeparator::Point);A date or an amount that cannot be read without guessing (31/02/2023, 1,234) throws a
Silarhi\Qif\Exception\ParseException. Every getter, and what the parser reads or ignores, is in
Parsing QIF files.
Write a QIF file
Section titled “Write a QIF file”Build Transaction objects, add them to a Writer, then print it or save it:
<?php
use Silarhi\Qif\Enums\Types;use Silarhi\Qif\Transaction;use Silarhi\Qif\Writer;
$writer = new Writer();
$writer->addTransaction( (new Transaction(Types::Bank)) ->setDate(new DateTimeImmutable('2026-01-15')) ->setDescription('Example Hardware Store') ->setAddress("1 Market Square\nSpringfield") ->setMemo('Drill and bits') ->setAmount(-118.99) ->setCategory('Home') ->addSplit('Home:Tools', -100) ->addSplit('Tax', -18.99, 'VAT') ->markAsCleared());
$writer->addTransaction( (new Transaction(Types::Bank)) ->setDate(new DateTimeImmutable('2026-01-31')) ->setDescription('Acme Corp') ->setAmount('2,400.00') ->setCategory('Income:Salary'));
echo $writer;!Type:BankD15/01/2026T-118.99LHomeSHome:Tools$-100STax$-18.99EVATCcPExample Hardware StoreA1 Market SquareASpringfieldMDrill and bits^!Type:BankD31/01/2026T2400LIncome:SalaryCPAcme Corp^$writer->saveToFile('/path/to/export.qif'); // or write it to diskThe fields the writer outputs, and their format, are in Writing QIF files.
