| Package Data | |
|---|---|
| Maintainer Username: | codedge |
| Maintainer Contact: | holger.loesken@codedge.de (Holger Lösken) |
| Package Create Date: | 2016-05-23 |
| Package Last Update: | 2025-09-16 |
| Home Page: | |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-10-29 03:02:59 |
| Package Statistics | |
|---|---|
| Total Downloads: | 1,613,915 |
| Monthly Downloads: | 32,290 |
| Daily Downloads: | 1,354 |
| Total Stars: | 293 |
| Total Watchers: | 6 |
| Total Forks: | 84 |
| Total Open Issues: | 2 |
This repository implements a simple ServiceProvider that creates a singleton instance of the Fpdf PDF library - easily accessible via a Facade in Laravel 5.
See FPDF homepage for more information about the usage.
$ composer require codedge/laravel-fpdf
Enjoy the auto discovery feature.
To use the static interfaces (facades) you need to add the following lines to your config/app.php. The [1] is for
registering the service provider, the [2] are for specifying the facades:
// config/app.php
return [
//...
'providers' => [
// ...
/*
* Application Service Providers...
*/
// ...
Codedge\Fpdf\FpdfServiceProvider::class, // [1]
],
// ...
'aliases' => [
// ...
'Fpdf' => Codedge\Fpdf\Facades\Fpdf::class, // [2]
]
Now you can use the facades in your application.
Run
php artisan vendor:publish --provider="Codedge\Fpdf\FpdfServiceProvider" --tag=config
to publish the configuration file to config/fpdf.php.
Open this file and enter the correct page settings, if you do not want the defaults.
If you want to use the facade you can see a basic example here:
// app/Http/routes.php | app/routes/web.php
Route::get('/', function () {
Fpdf::AddPage();
Fpdf::SetFont('Courier', 'B', 18);
Fpdf::Cell(50, 25, 'Hello World!');
Fpdf::Output();
});
Of course you can also inject the singleton instance via dependency injection. See an example here:
// app/Http/routes.php | app/routes/web.php
Route::get('/', function (Codedge\Fpdf\Fpdf\Fpdf $fpdf) {
$fpdf->AddPage();
$fpdf->SetFont('Courier', 'B', 18);
$fpdf->Cell(50, 25, 'Hello World!');
$fpdf->Output();
});