Which folders and files of Laravel we dont need on production (Web) server?

Viewed 569

Have done some website on Laravel framework. I did it on local server and now started to upload it on production (Web) server.

I realize, that Laravel have many and many files. I wonder, if I need to have them all on production server?

So want to ask, if some folders or files I dont need to upload on Web server? Have someone experience with it? Because I didnt find any quality information about it.

Thanks!

1 Answers

Take a look at the deployment guide here, for general information how to move to production.

Also you can take a look at the .gitignore file in the project root. Everything that is listed here isn't supposed to move to production.

This includes these files and directories:

/node_modules
/public/hot
/public/storage
/storage/*.key
/vendor
.env
.env.backup
.phpunit.result.cache
Homestead.json
Homestead.yaml
npm-debug.log
yarn-error.log

Especially the node_modules and vendor directory will contain lot's and lot's of files and libraries.

The contents of the vendor directory are described by composer.json / composer.lock These can also be installed directly on the production server by running:

composer install --optimize-autoloader --no-dev

The node_modules directory is usually just needed on the develop server. It's contents are described by package.json / package.lock. Once you build your final assets by running

npm run production

it's sufficient to upload the minified output files of that command (mostly .css and .js files) to production.

Related