Skip to main content

Installation

Get started with PHP FacturaE in your project by following these simple steps.

Requirements

PHP FacturaE requires PHP 8.2 or higher. Make sure your environment meets this requirement before installing.

PHP Version

"php": "^8.2"

Required PHP Extensions

The following extensions must be enabled in your PHP installation:

ext-openssl

Required for XAdES-EPES digital signatures and certificate handling

ext-dom

Required for XML generation and manipulation
These are standard PHP extensions and are typically enabled by default in most PHP installations.

Installing via Composer

1

Install the package

Run the Composer command to add PHP FacturaE to your project:
composer require php-facturae/php-facturae
If you’re starting a new project, you can combine this with composer init to create a new composer.json file.
2

Verify installation

After installation completes, verify the package is in your composer.json:
composer.json
{
    "require": {
        "php-facturae/php-facturae": "^1.0"
    }
}
3

Check PHP extensions

Verify the required extensions are enabled:
php -m | grep -E "openssl|dom"
You should see both openssl and dom in the output.

Verifying Your Setup

Create a test script to ensure everything is installed correctly:
verify.php
<?php

require_once 'vendor/autoload.php';

use PhpFacturae\Invoice;
use PhpFacturae\Party;

// Create a simple test invoice
$invoice = Invoice::create('TEST-001')
    ->seller(Party::company('B12345678', 'Test Company'))
    ->buyer(Party::company('B87654321', 'Client Company'))
    ->line('Test Product', price: 100.00, vat: 21);

echo "✓ PHP FacturaE is correctly installed!\n";
echo "Invoice number: " . $invoice->getNumber() . "\n";
Run the script:
php verify.php
You should see:
✓ PHP FacturaE is correctly installed!
Invoice number: TEST-001

Autoloading

PHP FacturaE uses PSR-4 autoloading. The namespace mapping is:
composer.json
{
    "autoload": {
        "psr-4": {
            "PhpFacturae\\": "src/"
        }
    }
}
This means:
  • PhpFacturae\Invoice maps to src/Invoice.php
  • PhpFacturae\Party maps to src/Party.php
  • PhpFacturae\Entities\Line maps to src/Entities/Line.php
  • And so on…
After requiring the Composer autoloader (vendor/autoload.php), all classes are automatically available — no manual imports needed.

Development Dependencies

If you plan to contribute or run tests, install dev dependencies:
composer install --dev
This includes:
  • PHPUnit 11.0+ — For running the test suite
  • PHPStan 2.0+ — For static analysis at level 8

Running Tests

vendor/bin/phpunit

Running Static Analysis

vendor/bin/phpstan analyse src --level=8

Troubleshooting

”ext-openssl is missing”

The openssl extension is required for digital signatures.
On Ubuntu/Debian:
sudo apt-get install php8.2-openssl
sudo systemctl restart php8.2-fpm
On macOS (Homebrew):
brew install [email protected]
On Windows: Edit php.ini and uncomment:
extension=openssl

“ext-dom is missing”

On Ubuntu/Debian:
sudo apt-get install php8.2-xml
sudo systemctl restart php8.2-fpm
On macOS (Homebrew):
brew install [email protected]
On Windows: Edit php.ini and uncomment:
extension=dom

“Class ‘PhpFacturae\Invoice’ not found”

Make sure you’re requiring the Composer autoloader:
require_once __DIR__ . '/vendor/autoload.php';
If the error persists, regenerate the autoloader:
composer dump-autoload

Optional: TSA Timestamping

For timestamp authority (TSA) support when signing invoices, you may need ext-curl:
# Ubuntu/Debian
sudo apt-get install php8.2-curl

# macOS
brew install [email protected]
TSA timestamping is optional but recommended for long-term signature validity. See the Signing documentation for details.

Next Steps

Quickstart Guide

Create your first complete invoice in under 5 minutes

API Reference

Explore the full API documentation
1

Installation complete

You’ve successfully installed PHP FacturaE!
2

Create your first invoice

Head to the Quickstart guide to generate a complete working invoice
3

Learn advanced features

Explore corrective invoices, digital signatures, split payments, and more

Build docs developers (and LLMs) love