PHP code example of greenterfin / xmldsig

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

    

greenterfin / xmldsig example snippets



use Greenter\XMLSecLibs\Sunat\SignedXml;

certPath = 'certifcate.pem'; // Antes convertir pfx -> pem (public+private key) 

$signer = new SignedXml();
$signer->setCertificateFromFile($certPath);

$xmlSigned = $signer->signFromFile($xmlPath);

file_put_contents("signed.xml", $xmlSigned);