简体   繁体   English

作曲家:巨大的供应商文件夹

[英]Composer: Huge vendor folder

I am experimenting with Composer and coming from a RubyGems/Bundler background, it does exhibit some interesting behavior. 我正在尝试使用Composer并来自RubyGems / Bundler背景,它确实展示了一些有趣的行为。

I tried creating a new Laravel project and to my surprise, I discover that I end up with a vendor folder that is beyond 70 megabytes in size. 我尝试创建一个新的Laravel项目,令我惊讶的是,我发现我最终得到了一个超过70兆字节的供应商文件夹。

While Laravel does offer a lot of functionality, I found the size to be bizarre, so I examined the contents of the vendor folder and discovered that it contains not just code, but also unit tests, documentation and entire git histories. 虽然Laravel确实提供了很多功能,但我发现它的大小很奇怪,所以我检查了vendor文件夹的内容,发现它不仅包含代码,还包含单元测试,文档和整个git历史记录。 For Swiftmailer, I even found lenghty RFC's for various e-mail standards. 对于Swiftmailer,我甚至为各种电子邮件标准找到了lenghty RFC。

While it's convenient to access specs and repository history for the dependencies, it does create a rather time-consuming deployment process and it litters the production server with irrelevant data. 虽然访问依赖项的规范和存储库历史记录很方便,但它确实创建了一个相当耗时的部署过程,并且使用不相关的数据来填充生产服务器。

I do understand that I could probably write an artisan command to "build" the app and dust off the dependencies by nuking all git histories, but it does seems like a dirty solution to a problem that has probably already been solved. 我确实理解我可能会编写一个工匠命令来“构建”应用程序并通过查看所有git历史来消除依赖关系,但它似乎是一个可能已经解决的问题的肮脏解决方案。

So the question is: Is there an approach to install composer dependencies, so only the code actually neccessary for running the (Laravel) app is downloaded? 所以问题是:是否有一种安装作曲家依赖关系的方法,所以只下载运行(Laravel)应用程序实际需要的代码?

Update: Using --prefer-dist 更新:使用--prefer-dist

I have discovered that you can pass the --prefer-dist option when creating a new project, .eg 我发现在创建新项目时可以传递--prefer-dist选项--prefer-dist

composer create-project laravel/laravel my-new-project --prefer-dist

This makes Composer prefer zipped distributions over obtaining the source directly from the VCS (eg GitHub) 这使得Composer更喜欢压缩分发而不是直接从VCS获取源代码(例如GitHub)

This rids you of the git histories and reduces the vendor folder to 17 megabytes. 这使您无法获取git历史记录并将供应商文件夹减少到17兆字节。 However, specs, documentation, eg is still included. 但是,仍然包括规格,文档等。 So it would be nice if there was a way to push it down to a couple of megabytes. 如果有办法将其降低到几兆字节,那就太好了。

You might want to take a look at this package: 您可能想看一下这个包:

https://github.com/barryvdh/composer-cleanup-plugin https://github.com/barryvdh/composer-cleanup-plugin

You could even improve upon this, I don't know if it removes the .git repositories as well etc.. 你甚至可以改进这一点,我不知道它是否也删除了.git存储库等等。

My vendor folder has a size of about 17 MB. 我的供应商文件夹大小约为17 MB。 Not sure what went wrong with your installation, but 70 MB is not the size it should have. 不确定您的安装出了什么问题,但70 MB不是它应该具有的大小。 I'm using Laravel 4.1. 我正在使用Laravel 4.1。 As far as I remebmer I downloaded it from Github as .zip ( https://github.com/laravel/laravel/archive/master.zip ) and then let Composer do the "install". 据我记得,我将它从Github下载为.zip( https://github.com/laravel/laravel/archive/master.zip ),然后让Composer进行“安装”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM