Install the NextPDF Cloudflare bridge
At a glance
Section titled “At a glance”Install the package with Composer. Then add a Hypertext Transfer Protocol (HTTP) client that implements PHP Standard Recommendation 18 (PSR-18) and factories that implement PSR-17. The bridge declares the interfaces; it does not bundle a concrete HTTP client.
Requirements
Section titled “Requirements”The bridge reads these dependencies from the require section of composer.json:
| Dependency | Constraint |
|---|---|
| PHP | >=8.4 <9.0 |
nextpdf/core | ^3.0 |
psr/http-client (PSR-18) | ^1.0 |
psr/http-factory (PSR-17) | ^1.1 |
psr/log (PSR-3) | ^3.0 |
The package autoloads NextPDF\Cloudflare\ from src/Cloudflare/
(PSR-4). It passes static analysis at PHPStan Level 10 and does not
ship an analyzer baseline.
Install the package
Section titled “Install the package”composer require nextpdf/cloudflareAdd an HTTP client and factories
Section titled “Add an HTTP client and factories”The bridge constructor requires a PSR-18 ClientInterface, a PSR-17
RequestFactoryInterface, and a PSR-17 StreamFactoryInterface. The
pinned-transport path also uses a PSR-17 ResponseFactoryInterface when
you supply one. You can use any conformant implementation. The README
names Guzzle as one example:
composer require guzzlehttp/guzzleGuzzle 7 provides the PSR-18 client and all four PSR-17 factory
interfaces. Symfony HttpClient, Buzz, and other conformant stacks also
work. The package is vendor-neutral by design. The
tests/Unit/Architecture/PsrConformanceTest.php test asserts that the
package depends only on PSR contracts, not on any concrete client.
Optional: local Chrome fallback
Section titled “Optional: local Chrome fallback”When the Worker is unreachable and fallback is enabled, the bridge can
delegate rendering to a local renderer. You provide that renderer
through NextPDF\Cloudflare\Contract\LocalRendererFactoryInterface.
The suggest block in composer.json names the first-party implementation:
composer require nextpdf/artisanInstalling nextpdf/artisan is not enough by itself. You must also pass
a LocalRendererFactoryInterface to the renderer constructor. If
Artisan is installed but no factory is wired, the bridge detects that
state and raises a CloudflareNotAvailableException. The exception
message states exactly that. See /integrations/cloudflare/production-usage/ for the wiring.
Verify the install
Section titled “Verify the install”<?php
declare(strict_types=1);
require __DIR__ . '/vendor/autoload.php';
use NextPDF\Cloudflare\CloudflareRendererConfig;
$config = new CloudflareRendererConfig( workerUrl: 'https://pdf-renderer.example.workers.dev/render', apiToken: 'placeholder',);
echo $config->isValid() ? "ready\n" : "incomplete\n";isValid() returns true when both workerUrl and apiToken are
non-empty. It does not contact the network. It only checks configuration
completeness, so you can use it as a deploy-time smoke test.
See also
Section titled “See also”- /integrations/cloudflare/configuration/ — all configuration options.
- /integrations/cloudflare/quickstart/ — run your first render.
- /integrations/cloudflare/boot-and-discovery/ — wire the bridge into a framework container.