1. Go to this page and download the library: Download kowts/efatura-cv 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/ */
use Kowts\Efatura\Domain\DocumentType;
$iud = Yii::$app->efatura->buildSequentialIud('2026-07-08', DocumentType::ElectronicInvoice);
$xml = Yii::$app->efatura->buildDfeXml($iud, $documento);
use Kowts\Efatura\Bridge\Yii2\EfaturaComponent;
use Kowts\Efatura\Config\EfaturaConfig;
use Kowts\Efatura\Efatura;
use Kowts\Efatura\Infrastructure\Sequence\PdoSequenceStore;
use Kowts\Efatura\Infrastructure\Submission\PdoSubmissionRegistry;
return [
'components' => [
'efatura' => [
'class' => EfaturaComponent::class,
'config' => [
// Mesma configuração fiscal do exemplo anterior.
],
'factory' => static function (EfaturaComponent $component): Efatura {
$pdo = Yii::$app->db->pdo;
$prefix = Yii::$app->db->tablePrefix;
return new Efatura(
EfaturaConfig::fromArray($component->config),
sequenceStore: new PdoSequenceStore($pdo, $prefix . 'efatura_sequences'),
submissionRegistry: new PdoSubmissionRegistry($pdo, $prefix . 'efatura_submissions'),
);
},
],
],
];
use Kowts\Efatura\Infrastructure\Sequence\PdoSequenceStore;
$pdo = new PDO('mysql:host=localhost;dbname=faturacao', 'utilizador', 'senha');
$sequences = new PdoSequenceStore($pdo);
$sequences->createTable(); // Execute uma vez, ou converta para uma migração.
$efatura = new Efatura($config, $sequences);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.