0

I'm new to Laravel. When I finally deploy my new web application to the host/live server, I realized that nearly 5,000 files were transferred to it.

I don't transfer node_modules dependencies, so it's not those file. Because I use webpack (Laravel Mix), I don't need the node_modules dependencies on the server, and it works just fine.

Here's the larger suspects. Do I need them on my host/live server at all? If so, why when the main part of my Laravel web application is just a few pages.

vendor/symfony = 1500 files
vendor/laravel = 900 files
vendor/mongodb = 500 files
vendor/nikic (php-parser) = 500 files
vendor/swiftmailer = 300 files
vendor/psy = 250 files

I realize I can call composer install once the application is deployed. But installing composer itself on a production server seems odd to me. In that case, I'd rather just transfer the files during deployment.

Mostly, I wonder why I need these at all. Are they just the overhead that ALL Laravel web applications require?

Steve Kennedy
  • 5,312
  • 3
  • 26
  • 41
  • I find Composer often includes test files from dependencies that aren't used in production, so you can delete those. Also see this: https://stackoverflow.com/questions/26930816/how-to-remove-unused-dependencies-from-composer – Dai Sep 07 '18 at 23:02
  • 1
    I would suggest downloading the _composer.phar_ archive to your production server, because it also handles **Auto-Load** and **Caching**. I would also suggest setting up a simple deployment system using git/webhooks that can run the most important commands on code update (migrate, cache etc). Check [Laravels Documentation](https://laravel.com/docs/5.6/deployment) – ege Sep 08 '18 at 01:33

1 Answers1

1

Yes. These files are used to generate the code (dependencies) necessary to run your application. For example, if you deleted this folder, you wouldn't be able to do any Laravel 'Magic' such as using Eloquent. While there are a lot of folders and files, it is necessary to keep them.

Here is a good article explaining what exactly the vendor folder is.

Note: When publishing to GitHub by default this vendor folder is ignored. Please see the .gitignore file in the root directory of your application.

J. Robinson
  • 931
  • 4
  • 17
  • 45