PHP code example of phpcfdi / sat-pys-scraper

1. Go to this page and download the library: Download phpcfdi/sat-pys-scraper 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/ */

    

phpcfdi / sat-pys-scraper example snippets



use GuzzleHttp\Client;
use PhpCfdi\SatPysScraper\Generator;
use PhpCfdi\SatPysScraper\Scraper;
use PhpCfdi\SatPysScraper\XmlExporter;

$scraper = new Scraper(new Client());
$generator = new Generator($scraper);
$types = $generator->generate();
$types->sortByKey();

foreach ($types as $type) {
    printf("Tipo: %s - %s\n", $type->key, $type->name);
    foreach ($type as $segment) {
        printf("  Segmento: %s - %s\n", $segment->key, $segment->name);
        foreach ($segment as $family) {
            printf("    Familia: %s - %s\n", $family->key, $family->name);
            foreach ($family as $class) {
                printf("      Clase: %s - %s\n", $class->key, $class->name);
            }
        }
    }
}

$exporter = new XmlExporter();
$exporter->export('output.xml', $types);