I am experimenting with Composer and coming from a RubyGems/Bundler background, it does exhibit some interesting behavior.
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.
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. For Swiftmailer, I even found lenghty RFC's for various e-mail standards.
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.
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?
--prefer-dist
I have discovered that you can pass the --prefer-dist
option when creating a new project, .e.g
composer create-project laravel/laravel my-new-project --prefer-dist
This makes Composer prefer zipped distributions over obtaining the source directly from the VCS (e.g. GitHub)
This rids you of the git histories and reduces the vendor folder to 17 megabytes. However, specs, documentation, e.g. is still included. So it would be nice if there was a way to push it down to a couple of megabytes.
The general recommendation is no. The vendor directory (or wherever your dependencies are installed) should be added to . gitignore / svn:ignore /etc. The best practice is to then have all the developers use Composer to install the dependencies.
The vendor is a subfolder in the Laravel root directory. It includes the Composer dependencies in the file autoload. php. Composer is a PHP based tool for dependency management. As a Laravel project works with many libraries, it requires the Composer for dependency management.
The vendor folder is where you usually (I'm using the word 'usually' because it's not exactly a rule but more of a preference in the coding community with the purpose of having a semantic directory structure) keep third-party resources(icons, images, codes, you name it) as opposed to a lib (library) folder where you or ...
You might want to take a look at this package:
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..
My vendor folder has a size of about 17 MB. Not sure what went wrong with your installation, but 70 MB is not the size it should have. I'm using 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".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With