2017 © Pedro Peláez
 

library ofxparser

Simple OFX file parser

image

asgrim/ofxparser

Simple OFX file parser

  • Friday, January 19, 2018
  • by asgrim
  • Repository
  • 8 Watchers
  • 63 Stars
  • 38,300 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 34 Forks
  • 13 Open issues
  • 10 Versions
  • 7 % Grown

The README.md

OFX Parser

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version License, (*1)

OFX Parser is a PHP library designed to parse an OFX file downloaded from a financial institution into simple PHP objects., (*2)

It supports multiple Bank Accounts, the required "Sign On" response, and recognises OFX timestamps., (*3)

Installation

Simply require the package using Composer:, (*4)

$ composer require asgrim/ofxparser

Usage

You can access the nodes in your OFX file as follows:, (*5)

$ofxParser = new \OfxParser\Parser();
$ofx = $ofxParser->loadFromFile('/path/to/your/bankstatement.ofx');

$bankAccount = reset($ofx->bankAccounts);

// Get the statement start and end dates
$startDate = $bankAccount->statement->startDate;
$endDate = $bankAccount->statement->endDate;

// Get the statement transactions for the account
$transactions = $bankAccount->statement->transactions;

Most common nodes are support. If you come across an inaccessible node in your OFX file, please submit a pull request!, (*6)

Investments Support

Investments look much different than bank / credit card transactions. This version supports a subset of the nodes in the OFX 2.0.3 spec, per the immediate needs of the author(s). You may want to reference the OFX documentation if you choose to implement this library. In particular, this does not currently process investment positions (INVPOSLIST) or referenced security definitions (SECINFO)., (*7)

This is not a pure pass-through of fields, such as this implementation in python: csingley/ofxtools. This package contains fields that have been "translated" on occasion to make it more friendly to those less-familiar with the investments OFX spec., (*8)

To load investments from a Quicken (QFX) file or a MS Money (OFX / XML) file:, (*9)

// You'll probably want to alias the namespace:
use OfxParser\Entities\Investment as InvEntities;

// Load the OFX file
$ofxParser = new \OfxParser\Parsers\Investment();
$ofx = $ofxParser->loadFromFile('/path/to/your/investments_file.ofx');

// Loop over investment accounts (named bankAccounts from base lib)
foreach ($ofx->bankAccounts as $accountData) {
    // Loop over transactions
    foreach ($accountData->statement->transactions as $ofxEntity) {
        // Keep in mind... not all properties are inherited for all transaction types...

        // Maybe you'll want to do something based on the transaction properties:
        $nodeName = $ofxEntity->nodeName;
        if ($nodeName == 'BUYSTOCK') {
            // @see OfxParser\Entities\Investment\Transaction...

            $amount = abs($ofxEntity->total);
            $cusip = $ofxEntity->securityId;

            // ...
        }

        // Maybe you'll want to do something based on the entity:
        if ($ofxEntity instanceof InvEntities\Transaction\BuyStock) {
            // ...
        }

    }
}

Fork & Credits

This is a fork of grimfor/ofxparser made to be framework independent. The source repo was designed for Symfony 2 framework, so credit should be given where credit due! Heavily refactored by Oliver Lowe and loosely based on the ruby ofx-parser by Andrew A. Smith., (*10)

The Versions

19/01 2018

dev-master

9999999-dev

Simple OFX file parser

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Oliver Lowe

parser finance ofx open financial exchange

26/09 2016

1.2.1

1.2.1.0

Simple OFX file parser

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Oliver Lowe

parser finance ofx open financial exchange

23/08 2016

dev-support-investments-ofx

dev-support-investments-ofx

Simple OFX file parser

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Oliver Lowe

parser finance ofx open financial exchange

23/08 2016

1.2.0

1.2.0.0

Simple OFX file parser

  Sources   Download

MIT

The Requires

  • php ~5.6|~7.0

 

The Development Requires

by Oliver Lowe

parser finance ofx open financial exchange

11/12 2015

1.1.1

1.1.1.0

Simple OFX file parser

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Oliver Lowe

parser finance ofx open financial exchange

13/04 2015

1.1.0

1.1.0.0

Simple OFX file parser

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Oliver Lowe

parser finance ofx open financial exchange

20/02 2015

1.0.3

1.0.3.0

Simple OFX file parser

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Oliver Lowe

parser finance ofx open financial exchange

12/01 2015

1.0.2

1.0.2.0

Simple OFX file parser

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Oliver Lowe

parser finance ofx open financial exchange

08/01 2015

1.0.1

1.0.1.0

Simple OFX file parser

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Oliver Lowe

parser finance ofx open financial exchange

23/07 2014

1.0.0

1.0.0.0

Simple OFX file parser

  Sources   Download

MIT

The Requires

  • php >=5.4

 

by Oliver Lowe

parser finance ofx open financial exchange