PHP code example of kubinyete / adiq-edi-php

1. Go to this page and download the library: Download kubinyete/adiq-edi-php 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/ */

    

kubinyete / adiq-edi-php example snippets


// Opening the document by providing a file path
$document = Document::open(__DIR__ . DIRECTORY_SEPARATOR . 'EDI_020_20231001_11111_0011_001111111_000111.txt');
// Metadata information can be found via
$metadata = $document->getMetadata();

dump([
    'fileVersion' => $metadata->version,
    'fileDate' => $metadata->date,
    'movement' => $metadata->movement,
    'acquirerName' => $metadata->acquirer,
    'establishmentCode' => $metadata->establishmentCode,
]);

// For each envelope available
foreach ($document->getEnvelopes() as $envelope) {
    /** @var Envelope $envelope */
    dump([
        'envelopeDate' => $envelope->date,
        'envelopeCurrencyCode' => $envelope->currencyCode,
        'entriesCount' => $envelope->registryTotalCount,
        'entriesCreditSum' => $envelope->registryTotalCreditAmount,
    ]);

    // For each entry (CV, AJ, CC) inside our envelope.
    foreach ($envelope->getEntries() as $entry) {
        /** @var EDIRegistry $entry */
        dump($registry);
    }
}