• This repository has been archived on 08/Sep/2020
  • Stars
    star
    108
  • Rank 320,268 (Top 7 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 11 years ago
  • Updated 3 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

πŸ’° OFX File Parser

OFX Parser

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version License

OFX Parser is a PHP library designed to parse an OFX file downloaded from a financial institution into simple PHP objects.

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

Installation

Simply require the package using Composer:

$ composer require asgrim/ofxparser

Usage

You can access the nodes in your OFX file as follows:

$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!

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).

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.

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

// 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.

More Repositories

1

year

:trollface: Year as a Service
202
star
2

yamldb

Don't use this, please.
PHP
35
star
3

quality-tutorial

Sample code and exercises for my quality PHP workshop
PHP
30
star
4

book-library

Demo application using Expressive that I use in talks
PHP
25
star
5

mini-mezzio

Minimal Application Factory for Mezzio
PHP
20
star
6

rust-ffi-test

Using a Rust lib in a PHP FFI test
Rust
18
star
7

side-effect

Side Effect Framework
PHP
16
star
8

godeploy

⚠️ Abandoned ⚠️
PHP
15
star
9

code-review-checklist

11
star
10

rmq-slides

Code and examples to go with my RabbitMQ presentation
PHP
10
star
11

basic-maths-compiler

Basic maths compiler for my AST talk
PHP
9
star
12

rmq-tutorial

Tutorial resources
PHP
7
star
13

random-status-middleware

Randomise the status code returned from a middleware pipeline.
PHP
6
star
14

directory-syncing-thing

A simple script that uses inotify to "sync" files quickly when they change from one directory to another
Shell
5
star
15

class-api-dumper

Small tool to dump a summary of a class's API
PHP
4
star
16

example-pie-extension

An example of a PIE-enabled PHP module
C
4
star
17

es-book-library

A book library demo using Eventsauce.io
PHP
3
star
18

joindin-random-feedback-selector

A little tool that selects random feedback from an event on Joind.in
PHP
3
star
19

zdt-memcache

Zend Developer Tools Memcache plugin
PHP
3
star
20

jamestitcumb

My personal website
PHP
2
star
21

darklord

Information and whatnot for Darklord MUD
HTML
2
star
22

mal

Mighty Asgrim's Library. Just a collection of lib classes for Zend Framework I've made that sort of make my life easier. Some of them may actually overlap ZF built-in functionality, but these are mainly just me messing around!
PHP
2
star
23

ha-php

PHP agent running my Pi that talks to Home Assistant
PHP
1
star
24

apoc

MUD
C
1
star
25

random-php-generator

cuz, why not
PHP
1
star
26

script-running-indicator

Just an Ubuntu indicator app to run a script
Python
1
star
27

scout-test-project

Testing out Scout APM
PHP
1
star
28

uuid2clip

A simple tool that generates a UUIDv4 and puts it in the clipboard
Rust
1
star
29

meet.asgrim.com

HTML
1
star
30

cleverbotselfchat

Just mucking around with Selenium
Java
1
star
31

zend-cache-example

Isolated Zend\Cache example
PHP
1
star
32

zfhtml5

Zend Framework HTML5 base project
JavaScript
1
star
33

phpstan-zend-framework

PHPStan extension for Zend Framework and Expressive
PHP
1
star
34

arson

Asgrim's Rust-based JSON viewer tool.
Rust
1
star