1. Go to this page and download the library: Download anglemx/sat-cfdi 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/ */
anglemx / sat-cfdi example snippets
<?
use Angle\CFDI\CFDI33;
use Angle\CFDI\XmlLoader;
// ...
// ...
// ...
$xmlFile = 'invoice.xml';
$loader = new XmlLoader();
$cfdi = $loader->fileToCFDI($xmlFile);
if (!$cfdi) {
// Parsing failed
// All the helper classes and utilities keep a log of errors that are meant for internal debugging
echo "Errors:" . PHP_EOL;
echo print_r($loader->getErrors(), true) . PHP_EOL;
// And the utilities also keep a log of validations, which are user-friendly and meant for public display
echo "Validations:" . PHP_EOL;
echo print_r($loader->getValidations(), true) . PHP_EOL;
}
// Parsing success!
print_r($cfdi);
// The validations log is also available upon success
echo "Validations:" . PHP_EOL;
echo print_r($loader->getValidations(), true) . PHP_EOL;