PHP code example of bluspark / dgfip-datamatrix

1. Go to this page and download the library: Download bluspark/dgfip-datamatrix 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/ */

    

bluspark / dgfip-datamatrix example snippets



use Bluspark\DgfipDatamatrix\DataMatrixGenerator;
use Bluspark\DgfipDatamatrix\DataMatrixReference;

$reference = new DataMatrixReference();
$reference
    ->setEmitterCode("...")
    ->setEstablishmentCode("...")
    ->setRevenueCode("...")
    ->setAccountantCode("...")
    ->setFiscalYear("...")
    ->setInvoiceNumber("...")
    ->setAmountInCents("...")
    ;

$generator = new DataMatrixGenerator();
$datamatrix = $generator->generate($reference);


echo "The datamatrix code is: " . $datamatrix->asString();

// For a PNG image
$png = $datamatrix->asPng();
file_put_contents("datamatrix.png", $png);

// For a SVG image
$svg = $datamatrix->asSvg();
file_put_contents("datamatrix.svg", $svg);