Read SIE files using PHP.
A memory efficient way to read an uploaded SIE file (Swedish Accounting File) and get information usable in a php application. The goal was that memory used should not exceed
the current file as the current public reposit (neam/php) sadly failed on larger files. This will parse large .se files without any issues using php standard file reader.
Requires
PHP 8.0
Benchmark
File containing 29 819 vouchers is processed in 0.1 seconds with a 1.5 mb memory usage.
Currently implemented features
- Open .se file
- Will parse the following flags:
#RES, #KONTO, #RAR, #UB, #IB, #FNAMN, #ORGNR, #VER, #TRANS - Character encoded to support transforming to json
How to use
use SieParser\Parser;
$parser = new Parser("PATH TO FILE");
$parser->getRes();
The above code snippet will parse your selected file. In the example you get the "res" flag from the file as an array. This can be encoded to json for even smaller memory footprint.
To be implemented
- Parse more flags
- Parse dimensions
- Write to SIE file from PHP objects