Why PHP 8.5+?
TCPDF-Next requires PHP 8.5+ by design. This is not an arbitrary constraint — every modern PHP feature used in the library directly benefits code quality, security, and developer experience.
PHP 8.5 Features We Use
| Feature | How It Benefits TCPDF-Next |
|---|---|
| Readonly classes | Immutable value objects (PageSize, Margin, Color, FontInfo) — no mutation bugs |
| Backed enums | Type-safe configuration (Orientation::Portrait, BarcodeType::QRCode, SignatureLevel::PAdES_B_LTA) |
| Named arguments | Self-documenting API calls — setSignature(certInfo: $cert, level: SignatureLevel::PAdES_B_B) |
| Union/intersection types | Precise parameter types across the API |
| DNF types | Complex type constraints for internal validation |
#[\SensitiveParameter] | Passwords and private keys never appear in stack traces (Aes256Encryptor, CertificateInfo, TsaClient) |
#[\NoDiscard] | Compiler warnings if you ignore return values from critical methods (FontManager::registerFont(), FormFlattener::flatten()) |
| Property hooks | Clean getter/setter patterns without boilerplate |
| Pipe operator | Streamlined internal data transformations |
| Fibers | Foundation for async PDF generation in queue workers |
"But My Server Runs PHP 8.1..."
Use Docker as an isolation layer. Your application can run any PHP version — TCPDF-Next runs inside a container.
Minimal Dockerfile
dockerfile
FROM php:8.5-cli
# Install required extensions
RUN apt-get update && apt-get install -y \
libicu-dev libpng-dev libjpeg-dev libwebp-dev \
&& docker-php-ext-configure gd --with-jpeg --with-webp \
&& docker-php-ext-install gd intl
# Install Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
COPY . /app
WORKDIR /app
RUN composer install --no-dev --optimize-autoloaderDocker Compose for Teams
yaml
services:
pdf-generator:
build: .
volumes:
- ./output:/app/output
command: php generate-pdf.phpLaravel with Docker
If your Laravel app runs PHP 8.2 but you need TCPDF-Next, run PDF generation as a microservice:
yaml
services:
app:
image: php:8.2-fpm
# Your Laravel app
pdf-service:
build:
context: ./pdf-service
dockerfile: Dockerfile
image: php:8.5-cli
volumes:
- shared-output:/output
volumes:
shared-output:Or use Laravel's queue system to dispatch PDF generation to a PHP 8.5 worker.
🐳 Docker for Legacy PHP Environments
Docker is the recommended approach for teams that cannot upgrade their production PHP version. The PDF generation process is isolated — it reads input, writes a PDF file, and exits. No shared state, no compatibility concerns.
The Trade-off
By requiring PHP 8.5+, TCPDF-Next gains:
- Smaller codebase — Modern features replace hundreds of lines of workarounds
- Stronger type safety — PHPStan level 8 with zero errors
- Better security —
#[\SensitiveParameter]prevents credential leaks in logs - Immutable objects — Readonly classes eliminate an entire category of bugs
- Self-documenting code — Enums replace magic strings, named arguments replace positional arrays
The library that serves you for the next decade should be built on the language features of the next decade.