Question

I'm trying to download TCPDF library to my project using Composer (Laravel 4), but I can't.

Sometimes this error occurs

(http://i.stack.imgur.com/aaPDz.jpg)http://mahdedu.org/1.jpg

and sometime this error

(http://i.stack.imgur.com/quXMB.jpg)http://mahdedu.org/2.jpg

I want to download it and add it in laravel manually without using composer.

Was it helpful?

Solution

When you say "without using composer", I'm going to assume you mean "without using composer for the download". With the following solution you'll still need to invoke a composer command, but its just to get the library auto-loading.

First step is to find a folder that makes sense for storing your local copy of TCPDF. I would recommend against using the vendor folder, because that folder is largely (solely?) managed by composer. For the sake of demonstration, let's create a new folder called app/vendor. Not the best choice, I know, but this is just a demonstration of one possible solution. Download TCPDF, unzip it and move the resulting tcpdf folder into app/vendor (so you should end up with app/vendor/tcpdf).

Second step is to add this folder to the autoload section of composer.json, as follows:

"autoload": {
    "classmap": [
        "app/commands",
        "app/controllers",
        "app/models",
        "app/database/migrations",
        "app/database/seeds",
        "app/tests/TestCase.php",
        "app/vendor/tcpdf" // <== HERE IT IS
    ]

Finally, run composer dump-autoload.

You should now be able to use the TCPDF library within your code without any external download dependencies. I tested this solution on a clean copy of Laravel 4.1 and it worked fine.

If anybody has a more appropriate suggestion as to the location of the tcpdf folder, please add a comment.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top