Install the NextPDF Laravel package
At a glance
Section titled “At a glance”Install nextpdf/laravel with Composer. Laravel auto-discovery registers the
service provider for you. Publish the configuration file when you want to
edit it. The package detects optional NextPDF extensions automatically.
Install
Section titled “Install”composer require nextpdf/laravelThe package declares the following constraints in its composer.json:
| Requirement | Constraint |
|---|---|
| PHP | >=8.4 <9.0 |
laravel/framework | ^12.0 |
nextpdf/core | ^3.0 || ^5.2 |
psr/http-client | ^1.0 |
The package autoloads through a single PHP Standard Recommendation 4 (PSR-4) map. The
NextPDF\Laravel\ prefix resolves to src/Laravel/. This follows the
PSR-4 prefix-to-base-directory rule (PSR-4 §3).
Conceptual overview
Section titled “Conceptual overview”After you run composer require, Laravel package auto-discovery reads the
extra.laravel block in this package’s composer.json. It then registers
the provider and the facade alias for you, so you do not need to edit
config/app.php by hand. The block looks like this:
{ "extra": { "laravel": { "providers": [ "NextPDF\\Laravel\\NextPdfServiceProvider" ], "aliases": { "Pdf": "NextPDF\\Laravel\\Facades\\Pdf" } } }}Laravel’s package documentation explains this behavior. The
extra.laravel.providers array registers service providers automatically, and the
extra.laravel.aliases array registers facade aliases automatically (Laravel 12
package development guide,
https://laravel.com/docs/12.x/packages, retrieved 2026-05-18).
Code sample — Quick start
Section titled “Code sample — Quick start”Use the nextpdf-config tag to publish the configuration file. This tag
name is defined in NextPdfServiceProvider::boot().
php artisan vendor:publish --tag=nextpdf-configThis writes config/nextpdf.php to your application. The provider also
merges the package default config under the nextpdf key during
register(), so the package works before you publish. Publishing makes
the file editable in your application.
Confirm that Laravel discovered the provider:
php artisan package:discover --ansiCode sample — Production
Section titled “Code sample — Production”Pin the constraint for reproducible deployments. Disable discovery explicitly only if you register the provider yourself:
{ "extra": { "laravel": { "dont-discover": [ "nextpdf/laravel" ] } }}When discovery is disabled, register the provider yourself in
bootstrap/providers.php:
<?php
declare(strict_types=1);
return [ App\Providers\AppServiceProvider::class, NextPDF\Laravel\NextPdfServiceProvider::class,];Optional extensions
Section titled “Optional extensions”The package lists optional companion packages under suggest in its
composer.json. It detects installed companions at runtime:
| Package | Effect when installed | Detection point |
|---|---|---|
nextpdf/artisan | Chrome DevTools Protocol (CDP) Hypertext Markup Language (HTML) renderer config is applied to the document binding when a Chrome factory class is present | NextPdfServiceProvider::register() checks for the Chrome browser-factory class |
nextpdf/premium | The existing container keys resolve PDF Advanced Electronic Signatures (PAdES B-B) signing, PDF/A archival, and e-invoice contract concretes | resolved lazily on first container resolution |
Install an extension the same way:
composer require nextpdf/artisanNo further wiring is needed. The provider detects the extension on its next registration cycle.
Edge cases & gotchas
Section titled “Edge cases & gotchas”- Publishing is idempotent. It does not overwrite an existing
config/nextpdf.php. Add--forcewhen you want to overwrite it on purpose. - The provider is deferred, so a successful
php artisan package:discoveris enough to confirm the package. The bindings themselves do not appear until the first resolve. - The package supports
nextpdf/coreon both the^3.0and^5.2major lines. Match the core constraint to the line your application pins. The Laravel adapter surface is the same across both. - The README badge and
composer.jsonagree on Apache-2.0. The package was relicensed from LGPL-3.0-or-later. Pre-migration tagged versions stay under the prior license (seeCHANGELOG.md).
Performance
Section titled “Performance”Resolving nextpdf/core dominates the composer require cost.
Provider registration adds no measurable boot cost because all bindings
are deferred closures. See /integrations/laravel/boot-and-discovery/ for
the first-resolve construction cost.
Security notes
Section titled “Security notes”Install from the canonical Packagist package nextpdf/laravel. The
package ships Software Package Data Exchange (SPDX) REUSE headers and an
Apache-2.0 NOTICE file. Pin the constraint in composer.json and commit
composer.lock so deployed workers resolve the verified dependency tree.
Conformance
Section titled “Conformance”| Claim | Source | Clause | reference_id |
|---|---|---|---|
| PSR-4 prefix maps to base directory | PSR-4 Autoloader | §3 |
The Laravel auto-discovery key names were verified against the official
Laravel 12 package development documentation
(https://laravel.com/docs/12.x/packages, retrieved 2026-05-18).
Commercial context
Section titled “Commercial context”nextpdf/premium adds signing, PDF/A, and e-invoice concretes as an optional Enterprise capability. You can adopt it without changing the Core package documented here. See https://nextpdf.dev/get-license/?intent=laravel-signing.
See also
Section titled “See also”- /integrations/laravel/overview/ — package architecture and binding table
- /integrations/laravel/quickstart/ — first runnable controller
- /integrations/laravel/configuration/ — every config key explained
- /integrations/laravel/boot-and-discovery/ — discovery internals and binding lifetimes