PHP code example of primehover / danfebr

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

    

primehover / danfebr example snippets


// Capturando a DANFE com o XML da NF-e
$xml = file_get_contents('/path/to/xml'); // deve ser uma string
$api = new API();
$danfe = $api->getDanfeByXML($xml);

header("Content-type: application/pdf");
echo $danfe;
die;

// Usando a Facade
$danfe = DanfeBR::getDanfeByXML($xml);
header("Content-type: application/pdf");
echo $danfe;
die;

// Captura uma DANFe com o XML da NF-e
$api->getDanfeByXML($xml);

// Captura um novo Captcha
$captcha = $api->getCaptcha();
$captcha->getCode(); // código de identificação do Captcha
$captcha->getImage(); // link da imagem do Captcha

// Captura o XML de acordo com o Captcha
$api->getXMLByCaptcha(Captcha $captcha, $key, $answer);

// Captura a DANFe de acordo com o Captcha
$api->getDanfeByCaptcha(Captcha $captcha, $key, $answer);