Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to install Composer on server? [closed]

I'm trying to deploy a Laravel application and wondering if Composer needs to be installed separately on the server?

like image 336
Sushant Avatar asked Sep 06 '25 02:09

Sushant


1 Answers

No, you can build your application on a separate server (or less optimal when working in a team, on your development machine) and then copy the project (including the installed vendors) onto your server. In fact it is quite common to build the application on a separate server and then only deploy the artifact (a tar.gz file, an os-package like deb or a built docker image) instead, in order to have a production system without tools/dependencies not required for running the actual application like git, composer, etc.

You might have to run additional commands, e.g. to make sure cache files are generated, but basically you run a composer install --dump-autoload --no-dev --prefer-dist (and possibly also --classmap-authoritative) to install the production dependencies, run your required artisan commands to copy assets into the public directory, build cache files, etc. and then transfer the whole project over to your server using your preferred method from rsync to any of the other ones mentioned above. There might still be some details you have to take care of, but by no means do you have to have composer installed on your production server.

like image 148
dbrumann Avatar answered Sep 09 '25 05:09

dbrumann