This project consists of a PHP parser for OFX (Open Financial Exchange) files, implemented using PHP 8.2. Our aim is to make the process of importing OFX files as straightforward and hassle-free as possible.
Simply require the package using Composer:
$ composer require kalisport/ofx-php-parserThis project primarily revolves around the OFX class in the Kalisport\OFX namespace. This class provides a static function parse() which is used to parse OFX data and return the parsed information. Here is a basic usage example:
<?php
require 'vendor/autoload.php';
use Kalisport\OFX\OFX;
try {
// Load the OFX data
$ofxData = file_get_contents('path_to_your_ofx_file.ofx');
// Parse the OFX data
$parsedData = OFX::parse($ofxData);
// $parsedData is an instance of OFXData which gives you access to all parsed data
// Access the sign-on status code
$statusCode = $parsedData->signOn->status->code;
// Accessing bank accounts data
$bankAccounts = $parsedData->bankAccounts;
foreach($bankAccounts as $account) {
echo 'Account ID: ' .$account->accountNumber . PHP_EOL;
echo 'Bank ID: ' .$account->routingNumber . PHP_EOL;
// Loop through each transaction
foreach ($account->statement->transactions as $transaction) {
echo 'Transaction Type: ' . $transaction->type . PHP_EOL;
echo 'Date: ' . $transaction->date . PHP_EOL;
echo 'Amount: ' . $transaction->amount . PHP_EOL;
}
}
} catch (Exception $e) {
echo 'An error occurred: ' . $e->getMessage();
}This library is an independent project; however, it draws significant inspiration from the work done on endeken-com/ofx-php-parser, which is itself a fork of asgrim/ofxparser, originally derived from grimfor/ofxparser.
We would like to express our appreciation to the developers of these projects for their valuable contributions. Our intention was not to create a direct fork, but rather to build upon their efforts and guide the library in a slightly different direction to better address our specific requirements.


