PHP code example of sabas / edifact

1. Go to this page and download the library: Download sabas/edifact library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

sabas / edifact example snippets


$p = new EDI\Parser();
$p->load($location);     // a local path to a file or a URL (if file_get_contents() allows for remote access)
$p->loadString($string); // a full message (single line text)
$p->loadArray($array);   // an array of strings (one segment per entry)

$c->errors();

$c->get();

$c = new EDI\Encoder($x, $compact = true);

$c = new EDI\Encoder();
$c->encode($array, false);

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

        $parser = new EDI\Parser();
        $parser->load($file);
        $segments = $parser->getRawSegments();
        $parsed = $parser->get();
        $analyser = new EDI\Analyser();
        $mapping = new EDI\MappingProvider('D95B');
        $analyser->loadSegmentsXml($mapping->getSegments());
        $analyser->loadSegmentsXml($mapping->getServiceSegments(), false);
        $analyser->loadMessageXml($mapping->getMessage('coparn'));
        $analyser->loadCodesXml($mapping->getCodes());
        $analyser->directory = 'D95B';
        $result = $analyser->process($parsed, $segments);                   


$p = new EDI\Parser();
$p->load($x);
$r = new EDI\Reader($p);
$sender = $r->readEdiDataValue('UNB', 2);
$Dt = $r->readUNBDateTimeOfPreparation();


$r->errors();

$r->getParsedFile();

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

$mapping = new EDI\Mapping\MappingProvider('D95B');

$analyser = new EDI\Analyser();
$segs = $analyser->loadSegmentsXml($mapping->getSegments());
$svc = $analyser->loadSegmentsXml($mapping->getServiceSegments(3));

$interpreter = new EDI\Interpreter($mapping->getMessage('CODECO'), $segs, $svc);
$prep = $interpreter->prepare($edi);

$interpreter->getJson()

$interpreter->getJsonServiceSegments()

$interpreter->getErrors()

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