Skip to content

Install the NextPDF Laravel package

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.

Terminal window
composer require nextpdf/laravel

The package declares the following constraints in its composer.json:

RequirementConstraint
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).

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:

resource: composer.json (extra.laravel)
{
"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).

Use the nextpdf-config tag to publish the configuration file. This tag name is defined in NextPdfServiceProvider::boot().

Terminal window
php artisan vendor:publish --tag=nextpdf-config

This 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:

Terminal window
php artisan package:discover --ansi

Pin the constraint for reproducible deployments. Disable discovery explicitly only if you register the provider yourself:

resource: opt-out pattern (Laravel 12 packages guide)
{
"extra": {
"laravel": {
"dont-discover": [
"nextpdf/laravel"
]
}
}
}

When discovery is disabled, register the provider yourself in bootstrap/providers.php:

resource: bootstrap/providers.php (manual registration)
<?php
declare(strict_types=1);
return [
App\Providers\AppServiceProvider::class,
NextPDF\Laravel\NextPdfServiceProvider::class,
];

The package lists optional companion packages under suggest in its composer.json. It detects installed companions at runtime:

PackageEffect when installedDetection point
nextpdf/artisanChrome DevTools Protocol (CDP) Hypertext Markup Language (HTML) renderer config is applied to the document binding when a Chrome factory class is presentNextPdfServiceProvider::register() checks for the Chrome browser-factory class
nextpdf/premiumThe existing container keys resolve PDF Advanced Electronic Signatures (PAdES B-B) signing, PDF/A archival, and e-invoice contract concretesresolved lazily on first container resolution

Install an extension the same way:

Terminal window
composer require nextpdf/artisan

No further wiring is needed. The provider detects the extension on its next registration cycle.

  • Publishing is idempotent. It does not overwrite an existing config/nextpdf.php. Add --force when you want to overwrite it on purpose.
  • The provider is deferred, so a successful php artisan package:discover is enough to confirm the package. The bindings themselves do not appear until the first resolve.
  • The package supports nextpdf/core on both the ^3.0 and ^5.2 major 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.json agree on Apache-2.0. The package was relicensed from LGPL-3.0-or-later. Pre-migration tagged versions stay under the prior license (see CHANGELOG.md).

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.

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.

ClaimSourceClausereference_id
PSR-4 prefix maps to base directoryPSR-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).

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.

  • /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