PHP code example of silarhi / qif-library

1. Go to this page and download the library: Download silarhi/qif-library library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

silarhi / qif-library example snippets


use Silarhi\Qif\Enums\Types;
use Silarhi\Qif\Parser;
use Silarhi\Qif\Transaction;
use Silarhi\Qif\Writer;

// Parse
foreach (Parser::parseFile('/path/to/export.qif')->getTransactions() as $transaction) {
    $transaction->getDate();        // ?DateTimeImmutable
    $transaction->getAmount();      // ?float
    $transaction->getDescription(); // ?string, the payee
}

// Write
$writer = new Writer();
$writer->addTransaction(
    (new Transaction(Types::Bank))
        ->setDate(new DateTimeImmutable('2026-01-31'))
        ->setDescription('Acme Corp')
        ->setAmount(2400)
        ->setCategory('Income:Salary')
);
$writer->saveToFile('/path/to/export.qif');