2017 © Pedro PelĂĄez
 

library edifact

Tools in PHP for UN/EDIFACT

image

dbrkls/edifact

Tools in PHP for UN/EDIFACT

  • Friday, May 13, 2016
  • by uldisn
  • Repository
  • 1 Watchers
  • 1 Stars
  • 531 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 43 Forks
  • 0 Open issues
  • 2 Versions
  • 1 % Grown

The README.md

edifact

Tools to process EDI messages in UN/EDIFACT format, (*1)

Supported syntax is version 3., (*2)

It's provided in a Composer package:, (*3)

composer require sabas/edifact, (*4)

The mapping xml files are provided in a separate repository (https://github.com/sabas/edifact-data). To get them within the repository remember to clone with the --recursive flag, or download them with git submodule update --init --recursive, (*5)

EDI/Parser

Given an edi message checks the syntax, outputs errors and returns the message as a multidimensional array., (*6)

INPUT, (*7)

$c = new Parser($x);

Where $x could be: * a url * a string (wrapped message) * an array of strings (a segment per entry), (*8)

OR, (*9)

```php $c = new Parser(); $c->load($file); $c->loadString($string);, (*10)


**OUTPUT** Errors ```php $c->errors();

Array, (*11)

$c->get();

EDI/Encoder

Given a multidimensional array (formatted as the output of the parser), returns an EDI string, optionally one segment per line., (*12)

INPUT, (*13)

$c = new Encoder($x, $wrap = true);

$x is a multidimensional array where first dimension is the EDI segment, second contains elements: * single value * array (representing composite elements), (*14)

$wrap is a boolean, if you need a segment per line. Set to false to disable wrapping, (*15)

OR, (*16)

$c = new Encoder();
$c->encode($array, $wrap);

OUTPUT, (*17)

$c->get(); // returns String

EDI/Analyser

Create from EDI file readable structured text with comments from segments.xml., (*18)

INPUT, (*19)

$analyser = new EDI\Analyser();
$analyser->loadSegmentsXml('edifact/src/EDI/Mapping/d95b/segments.xml');
  • $url is the path to orginal EDI message file
  • $parsed is a by EDI\Parser() created EDI messages array

TEXT OUTPUT, (*20)

$analyser->process($parsed); // returns text

Or, (*21)

$analyser->process($parsed, $rawSegments);
  • $rawSegments (optional) is segments in raw format from EDI\Parser::getRawSegments to be printed before each segment in the analysed result

JSON OUTPUT Get a json representation of the array, with the element names as key., (*22)

$analyser->process($parsed);
$json = $analyser->getJson();

EDI/Reader

Read from EDI file requested segment element values., (*23)

INPUT, (*24)

$r = new Reader($x);
$sender = $r->readEdiDataValue('UNB', 2);
$Dt = $r->readUNBDateTimeOfPpreperation();

Where X could be: * a url * a string (wrapped message) * an array of strings (a segment per entry), (*25)

OR, (*26)

$c = new Parser($x);

$r=new Reader();
$r->setParsedFile($c);
$sender = $r->readEdiDataValue('UNB', 2);
$Dt = $r->readUNBDateTimeOfPpreperation();

OUTPUT Errors, (*27)

$c->errors();

Array, (*28)

$c->get();

EDI/Interpreter

Organizes the data parsed by EDI/Parser using the xml description of the message and the xml segments., (*29)

INPUT, (*30)

$p=new EDI\Parser($edifile);
$edi = $p->get();

$analyser = new EDI\Analyser();
$segs =$analyser->loadSegmentsXml('vendor/sabas/edifact-data/D95B/segments.xml');

$interpreter = new EDI\Interpreter('vendor/sabas/edifact-data/D95B/messages/codeco.xml', $segs);
$prep = $interpreter->prepare($edi);

OUTPUT, (*31)

Json, (*32)

$interpreter->getJson()

Errors (per message), (*33)

$interpreter->getErrors()

Example

Edifact, (*34)

DTM+7:201309200717:203', (*35)

Array, (*36)

['DTM',['7','201309200717','203']]

Syntax data

Processed from EDI PEAR Package by David JEAN LOUIS (izi), downloadable from https://code.google.com/p/izi-sandbox/source/browse/trunk/php/php_edi/., (*37)

Notes

Valid characters are: A-Za-z0-9.,-()/'+:=?!"%&*;<> UNECE, (*38)

The Versions

13/05 2016

dev-master

9999999-dev https://github.com/sabas/edifact

Tools in PHP for UN/EDIFACT

  Sources   Download

LGPL-3.0+

The Development Requires

by Emil Vikström

container message edi edifact

18/04 2016

dev-FORMERGE

dev-FORMERGE https://github.com/sabas/edifact

Tools in PHP for UN/EDIFACT

  Sources   Download

LGPL-3.0+

The Development Requires

by Emil Vikström

container message edi edifact