NextPDF Symfony boot and discovery
At a glance
Section titled “At a glance”The kernel registers NextPdfBundle. The bundle’s Dependency Injection (DI)
extension loads services.php and resolves the configuration tree into
container parameters. One compiler pass then wires optional extensions and font
warmup.
How Symfony Flex picks up the bundle
Section titled “How Symfony Flex picks up the bundle”The bundle composer.json declares an auto-registration hint:
{ "extra": { "symfony": { "bundles": { "NextPDF\\Symfony\\NextPdfBundle": "all" } } }}In a Symfony Flex application, this hint adds NextPDF\Symfony\NextPdfBundle
to config/bundles.php for every environment (all). Without Flex, add the
bundle manually in config/bundles.php. Symfony documents the bundle
registration model at (https://symfony.com/doc/current/bundles.html). The
bundle’s classes autoload under the PHP Standard Recommendation (PSR)-4 prefix
NextPDF\Symfony\, mapped to src/Symfony/. A PSR-4 autoloader maps the
namespace prefix to that base directory (PSR-4 §2).
Boot sequence
Section titled “Boot sequence”The boot sequence, verified against the bundle source:
- Kernel registers bundles.
Kernel::registerBundles()readsconfig/bundles.phpand instantiatesNextPDF\Symfony\NextPdfBundle, which extendsSymfony\Component\HttpKernel\Bundle\Bundle. - Bundle build.
NextPdfBundle::build()calls the parent method and then registers one compiler pass:OptionalExtensionPass.NextPdfBundle::getPath()returns the package root. - Extension load. The DI extension
NextPDF\Symfony\DependencyInjection\NextPdfExtension(aliasnextpdf) runsprocessConfiguration()againstConfiguration. It stores the resolved values asnextpdf.*container parameters, then loadsconfig/services.phpthrough aPhpFileLoader. - Required-extension guard.
NextPdfExtension::load()finishes by asserting thatext-mbstringandext-zlibare present, and fails fast if they are not. - Compiler pass runs. During container compilation,
OptionalExtensionPass::process()configures extension availability flags onPdfFactory, conditionally registers the signer and time-stamping authority (TSA) client, and schedules font-registry warmup and lock. - Container compiled and cached. Symfony writes the compiled container.
cache:warmupperforms this step before traffic reaches the application.
Compiler passes
Section titled “Compiler passes”The bundle registers exactly one pass,
NextPDF\Symfony\DependencyInjection\Compiler\OptionalExtensionPass, in
NextPdfBundle::build(). It runs in the default (before-optimization) pass
group. The pass performs four steps. Each step is guarded, so it does nothing
when its inputs are absent:
- Extension flags — adds
setArtisanAvailable(...)andsetProAvailable(...)method calls to thePdfFactorydefinition. The values come from compile-timeclass_existsprobes for the Artisan browser factory and the Pro PDF/A class. - Signer registration — registers a certificate-info factory and a signer
service for the baseline B-B profile when
nextpdf.signatureis present,enabledis true, and a certificate is set. - TSA client — registers a TSA client service when
nextpdf.tsahas a Uniform Resource Locator (URL). - Font warmup — adds
warmup()andlock()method calls to the font-registry definition whennextpdf.preload_fontsis non-empty.
Container bindings
Section titled “Container bindings”config/services.php defines the services. The document service
nextpdf.document (aliased to NextPDF\Contracts\PdfDocumentInterface and
NextPDF\Core\Document) is non-shared: each resolution returns a fresh
document. PSR-11 explicitly permits this behavior; successive get() calls for
one id may return different values (PSR-11 §1.1.2). The font registry is shared
and locked after warmup. The image registry is shared and tagged
kernel.reset. The full table is in /integrations/symfony/configuration/.
Configuration resolution order
Section titled “Configuration resolution order”- Built-in defaults from
Configuration(getConfigTreeBuilder()). - Application overrides in
config/packages/nextpdf.yaml, plus environment overrides underconfig/packages/<env>/. - Symfony resolves
%kernel.*%parameter placeholders. For example,fonts_pathdefaults to%kernel.project_dir%/resources/fonts. NextPdfExtension::load()writes the merged result tonextpdf.*container parameters thatservices.phpand the compiler pass consume.
Invalid values fail at step 1–2 with a Symfony
InvalidConfigurationException.
Diagnostics
Section titled “Diagnostics”php bin/console debug:container nextpdfphp bin/console debug:config nextpdfphp bin/console cache:clearThe first command lists the registered services. The second prints the merged configuration. The third rebuilds the container and re-runs the compile-time extension probes.
Conformance
Section titled “Conformance”Each row is a normative claim on this page, pinned to a full 64-hex
reference_id from the gated standards development organization (SDO) corpus.
Provenance (corpus manifest, retrieval transport) lives in
_sidecars/rag-citations.yaml.
| Spec | Clause | reference_id | Claim |
|---|---|---|---|
| PSR-11 | psr_11_container#1.1.2.p3.b | Container resolution may differ per call | |
| PSR-4 | psr_4_autoload#x1.x2.p5 | Namespace-prefix to base-directory mapping |
See also
Section titled “See also”- /integrations/symfony/integration/ — end-to-end wiring reference.
- /integrations/symfony/install/ — installation and registration.
- /integrations/symfony/configuration/ — full configuration tree and service table.
- /integrations/symfony/overview/ — capability summary.