Skip to main content

Overview

This guide helps you migrate to LibreDTE Core and understand the requirements for running the library.

PHP Version Requirements

LibreDTE Core requires PHP 8.5 or higher. Ensure your environment meets this requirement before proceeding.

Required PHP Extensions

The following PHP extensions are mandatory:
  • ext-curl - For HTTP requests to SII webservices
  • ext-json - For JSON data handling
  • ext-mbstring - For multibyte string operations
  • ext-openssl - For certificate and signature operations
  • ext-soap - For SOAP webservice communication with SII

System Requirements

Composer Dependencies

LibreDTE Core uses modern PHP packages:
  • Symfony Components (^7.4): Cache, Filesystem, Mailer, MIME
  • PDF Generation: mPDF (^8.2) and TCPDF (^6.11)
  • CSV Processing: League CSV (^9.28)
  • Date/Time: Carbon (^3.11)
  • Security: phpseclib (^3.0)

Development Requirements

For development environments, you’ll also need:
  • ext-xdebug - For code coverage
  • PHP CS Fixer (^3.94) - Code style
  • PHPStan (^1.12) - Static analysis
  • PHPUnit (^11.5) - Testing framework

Major Changes

Architecture

LibreDTE Core uses a component-based architecture with workers, strategies, and factories for maximum flexibility and testability.

Package Structure

The library is organized into packages:
  • Billing Package - Main package for electronic invoicing
    • Document Component - Document creation and validation
    • Trading Parties Component - Emisor/Receptor management
    • Integration Component - SII webservice integration
    • Exchange Component - Document exchange via email/SII
    • Identifier Component - CAF (Folio) management
    • Ownership Transfer Component - Guía handling

Namespace Changes

All classes use the namespace:
libredte\lib\Core\Package\Billing\...

Migration Steps

1

Update PHP Version

Ensure your server is running PHP 8.5 or higher:
php -v
2

Install Required Extensions

Verify all required PHP extensions are installed:
php -m | grep -E "curl|json|mbstring|openssl|soap"
3

Update Composer Dependencies

Install LibreDTE Core via Composer:
composer require libredte/libredte-lib-core
4

Update Your Code

Migrate to the new component-based architecture. See the Examples page for code samples.
5

Test Your Integration

Run your test suite to ensure compatibility:
vendor/bin/phpunit

Environment Configuration

SII Environments

LibreDTE Core supports two SII environments:
  • Certification - For testing (SiiAmbiente::CERTIFICACION)
  • Production - For live operations (SiiAmbiente::PRODUCCION)

Certificate Configuration

For SII integration, you need a valid digital certificate:
use Derafu\Certificate\Service\CertificateLoader;

$certificateLoader = new CertificateLoader();
$certificate = $certificateLoader->loadFromFile(
    '/path/to/certificate.pfx',
    'certificate-password'
);

Breaking Changes

The library now uses strict types (declare(strict_types=1)) throughout. Ensure your code passes correct data types.

Type Safety

All methods use strict type hints and return types. Update your code accordingly:
// Old (loose types)
$folio = "123";

// New (strict types)
$folio = 123;

Getting Help

If you encounter issues during migration:

Next Steps

After migrating:
  1. Review the Examples for common use cases
  2. Read the API Reference for detailed documentation
  3. Join the LibreDTE community for support

Build docs developers (and LLMs) love