Download tcpdf manually without using composer in Laravel 4

放肆的年华 提交于 2019-12-20 06:39:46

问题


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)

and sometime this error

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

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


回答1:


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.



来源:https://stackoverflow.com/questions/22144229/download-tcpdf-manually-without-using-composer-in-laravel-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!