Search code examples
laravel-5tcpdflaravel-artisanphp-5.5

Laravel 5.2.45 Tcpdf installation failed with php version 5.5.11


I need to generate a PDF using TDPDF with Laravel 5.2.45. I used the following command (reference: here):

composer require elibyy/tcpdf-laravel

and received the following message: enter image description here

Message: Your PHP version <5.5.11> does not satisfy that requirement.

Is there any other way to download TCPDF with Laravel if my PHP version do not satisfy the requirement?


Solution

  • I updated my composer with following command

    composer update
    

    Then added the following line to my composer.json file

    {
    "require": {
        "elibyy/tcpdf-laravel": "5.4.*"
    } }
    

    Next added the service provider to config/app.php.

    'providers' => [
    //...
    Elibyy\TCPDF\ServiceProvider::class,
    ]
    //...
    'aliases' => [
    //...
    'PDF' => Elibyy\TCPDF\Facades\TCPDF::class
    ]
    

    and again run the following command

    composer update
    

    And then to my controller I added the following lines:

    use PDF; // at the top of the file
    
    PDF::SetTitle('Hello World');
    PDF::AddPage();
    PDF::Write(0, 'Hello World');
    PDF::Output('hello_world.pdf');
    

    Now I am able to generate a PDF.