4

I have a Yii 2 web application which uses Composer for its dependencies. How am I supposed to deploy this application at a production server without having to run composer? What I would like to be done is to zip the whole application directory at the development server, copy it to the production server, unzip it and have it deployed there without any action run by composer.

2
  • So why don't you zip it up? Composer is just a lot easier, but you can still use the methods of deployment that existed before composer Commented May 17, 2015 at 7:07
  • I did try to zip it and copy it to the other system, but when I call the application, it fails with a ReflectionException error, which means the class autoloading does not work, it does not find the necessary class files. If I run composer install at the system, then it loads ok. Commented May 17, 2015 at 7:09

1 Answer 1

2

I found the solution. Run:

composer install --prefer-dist --no-dev --optimize-autoloader

at the development system and to then copy the whole directory to the production server.

From the documentation:

--prefer-dist: Reverse of --prefer-source, Composer will install from dist if possible. This can speed up installs substantially on build servers and other use cases where you typically do not run updates of the vendors. It is also a way to circumvent problems with git if you do not have a proper setup.

--no-dev: Skip installing packages listed in require-dev. The autoloader generation skips the autoload-dev rules.

--optimize-autoloader (-o): Convert PSR-0/4 autoloading to classmap to get a faster autoloader. This is recommended especially for production, but can take a bit of time to run so it is currently not done by default.

Sign up to request clarification or add additional context in comments.

1 Comment

Can you please reference some documentation for the command & flags you have used here?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.