How to install specific files from a package using composer.json

旧街凉风 提交于 2019-12-13 06:18:39

问题


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.

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?

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

please assist.

possible duplicate of this but has not been answered too!


回答1:


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.

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.



来源:https://stackoverflow.com/questions/25081951/how-to-install-specific-files-from-a-package-using-composer-json

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