I'm trying to deploy a Laravel application and wondering if Composer needs to be installed separately on the server?
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.
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