PHP code example of clonixdev / sri-signer

1. Go to this page and download the library: Download clonixdev/sri-signer 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/ */

    

clonixdev / sri-signer example snippets


use DazzaDev\SriSigner\Signer;

// Instanciar el signer
$signer = new Signer(
    certificatePath: __DIR__ . '/certificado.p12',
    certificatePassword: 'clave_certificado',
);

// XML como string o DOMDocument
$xmlString = file_get_contents(__DIR__ . '/factura.xml');

// Cargar el XML en el signer
$signer->loadXML($xmlString);

// Firmar el XML
$signedXML = $signer->sign();