Composer setup · 5 min read

Installation

Install the Laravel package, publish the configuration file, and connect it to the API key from your BladePDF dashboard.

Requirements

Requirement Version Why
PHP 8.2+ The package uses modern typed PHP.
Laravel components 10.x through 13.x HTTP client, support helpers, and view rendering.
BladePDF account Active account Provides API keys, cloud templates, assets, analytics, and webhooks.

Install the package

Terminal
bash
 1composer require bladepdf/laravel

Laravel package auto-discovery registers the service provider and the BladePDF facade alias automatically.

Publish the config

Terminal
bash
 1php artisan vendor:publish --tag=bladepdf-config

This creates config/bladepdf.php. The defaults are usually enough for local development.

Add your API key

Create an API key in the dashboard and place it in your environment file.

.env
env
 1BLADEPDF_API_KEY=blpdf_xxxxxxxxxxxxxxxxxxxxxxxx
Keep API keys server-side

Only call BladePDF from trusted backend code. Do not expose your API key in JavaScript, mobile apps, public repositories, or browser requests.

Verify the installation

Add a temporary route and request it from your browser or an HTTP test.

routes/web.php
php
 1use BladePDF\Laravel\Facades\BladePDF;
 2
 3Route::get('/bladepdf-check', function () {
 4    return BladePDF::fromHtml('<h1>BladePDF is installed</h1>')
 5        ->format('A4')
 6        ->render()
 7        ->response('check.pdf');
 8});

Importing the facade

Use the package facade directly:

PHP
php
 1use BladePDF\Laravel\Facades\BladePDF;

If you prefer a shorter alias in your own application, create one in your app code, but the official docs use BladePDF::.

Was this page helpful?
Let us know if something's missing or unclear.