Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

thebigk's avatar
Level 13

Deployment to Production Questions

I'm currently figuring out the right way to deploy the Laravel app on production server. I'm using GIT, while keeping the actual repo and Work Tree different; it works very well. I've referred to the documentation but I feel it's not complete - https://laravel.com/docs/5.6/deployment

Would really appreciate if someone could help me understand the following -

  1. Documentation says you need to run composer install --optimize-autoloader. But it does not talk about running composer install --no-dev. Is the second command required?

  2. Do we need to install node.js and npm on the server and run npm run prod? My best guess is that I should run these commands on my local dev machine and simply upload stuff to live server.

Thank you for your time and I look forward to having your responses.

0 likes
4 replies
yidekoh556's avatar

I'm not pro of using Git from local to server deployment. But, what I did was manually uploading files using FTP. I followed the YouTube videos "How to deploy Laravel to shared hosting". It worked for me very well. I followed those tutorials as there was no access to ssh/terminal of online server.

petrit's avatar
  1. Always you have to run 'composer install' command when you deploy your files for the first time on server. If any update is done on composer.json then you should run 'composer update'.

  2. For processing js and css files you are not forced to use npm. It is on your own how you want to organize css and js files.

thebigk's avatar
Level 13

Thanks @petrit . Which command should I run - composer install --optimize-autoloader OR composer install --no-dev

  1. Yes, that makes sense. No point in running NPM install. But then, what does the node_modules directory do in laravel project?
rumm.an's avatar

I think its better to run npm run prod on the production server and push ignoring public assets, rather than running on development server and pushing your public assets, whenever you push changes that requires compiling assets. But either way works, its all about your workflow which you feel better.

Please or to participate in this conversation.