Outils pour utilisateurs

Outils du site


devweb:laravel:fpdf (lu 24307 fois)

Fpdf

Pour ajouter Fpdf à laravel

To your composer.json file, add:

"require-dev": {
    "anouar/fpdf": "dev-master"
}

Then update your Laravel project,

composer update

If not already installed laravel framework use,

composer install

Then go to app/config/app.php and to the providers array add,

'Anouar\Fpdf\FpdfServiceProvider',

Now it’s look like,

'providers' => array(
    // ...
 
    'Anouar\Fpdf\FpdfServiceProvider',
)

Finally, add the alias to app/config/app.php, within the aliases array.

'aliases' => array(
    // ...
 
    'Fpdf'    => 'Anouar\Fpdf\Facades\Fpdf',
)

Now you can use Fpdf anywhere like,

In app/routes.php

Route::get('pdf', function(){
 
        Fpdf::AddPage();
        Fpdf::SetFont('Arial','B',16);
        Fpdf::Cell(40,10,'Hello World!');
        Fpdf::Output();
        exit;
 
});

Then test it with your url like,

http://localhost/laravel/pdf

You can see the Packagist https://packagist.org/packages/anouar/fpdf

And the GitHub Repo here https://github.com/xroot/laravel-fpdf

devweb/laravel/fpdf.txt · Dernière modification: 28-02-2014 15:37 de edmc73