如何使用composer.json从软件包安装特定文件 [英] How to install specific files from a package using composer.json

查看:537
本文介绍了如何使用composer.json从软件包安装特定文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一页脚本来完成一个相对简单的任务.因此,我决定使用蓬勃发展Unframework ,它提供了一堆可以单独使用的很棒的类.

I am writing a 1 page script to do a relatively simple task. So I decided to use Flourish Unframework which provides a bunch of cool classes that can used separately.

我只想使用特定的类,例如fDatabase,但是composer让我们下载整个软件包!

I only want to use specific classes, say fDatabase, however composer let's download the entire package!

我知道我可以删除不需要的文件,但是作曲家有没有办法让我需要特定的文件?

I know I could just delete the unwanted files BUT is there a way that composer could just let me require specific files?

不是我想要的,因为它只是自动加载并请注意从整个软件包中安装1个文件.

This is not what I am looking for because it's just autoload and note installing 1 file from an entire package.

请协助.

的可能副本,但是也没有得到答案!

possible duplicate of this but has not been answered too!

推荐答案

Composer仅允许安装整个软件包.通常,仅安装运行唯一功能所需的文件几乎是不可能的,因为所需的文件/类可能包含需要另一个类的代码.

Composer only allows installing the whole package. Only installing the files necessary to run the only one function you need is next to impossible to do in general, because the file/class you need might have code that needs one other class.

如何检测该类?可以使用变量来实例化类,可以使用多个字符串来连接类名. Composer必须检测并可能执行创建类名的代码.

How to detect that class? Classes can be instantiated with variables, the classname could be concatenated with several strings. Composer would have to detect and possibly execute the code that creates class names.

如果您真的担心上载太多代码,则可以搜索文件更少的更合适的程序包,自己安装该程序包并删除不需要的东西,或者只是使用它这样.

If you are really concerned about uploading too much code, you could either search for a more appropriate package with less files, do the installation of this package yourself and remove the things you don't need, or simply just use it the way it is.

这篇关于如何使用composer.json从软件包安装特定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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