在Laravel 4中手动下载tcpdf而不使用composer [英] Download tcpdf manually without using composer in Laravel 4

查看:380
本文介绍了在Laravel 4中手动下载tcpdf而不使用composer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Composer(Laravel 4)将TCPDF库下载到我的项目,但我不能。



有时会出现此错误



()


$ b

解决方案

当你说without时,使用 composer ,我假设你的意思是不使用 composer 下载。使用以下解决方案,您仍然需要调用 composer 命令,但它只是为了让库自动加载。



第一步是找到一个文件夹,用于存储TCPDF的本地副本。我会建议使用vendor文件夹,因为该文件夹在很大程度上(仅?)由 composer 管理。为了演示,让我们创建一个名为 app / vendor 的文件夹。不是最好的选择,我知道,但这只是一个可能的解决方案的示范。下载TCPDF,解压缩它并将生成的 tcpdf 文件夹移动到 app / vendor



第二步是将此文件夹添加到的自动加载部分。c $ c> app / vendor / tcpdf > composer.json ,如下所示:

 autoload:{
classmap :[
app / commands,
app / controllers,
app / models,
app / database / migrations,
app / database / seeds,
app / tests / TestCase.php,
app / vendor / tcpdf//< == Heree is is
]

最后,运行 composer dump-autoload



您现在应该能够在代码中使用TCPDF库,而不需要任何外部下载依赖。我在Laravel 4.1的一个干净的副本上测试了这个解决方案,它工作正常。



如果任何人有一个更合适的建议, $ c> tcpdf 文件夹,请添加评论。


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.

解决方案

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.

这篇关于在Laravel 4中手动下载tcpdf而不使用composer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆