I have developed a composer laravel based project that I need to install on a remote production server. The problem is I have limited permission/ access so my option is to "archive" the package( using composer archive
) and unpack on the production.
What folders do I need to archive and how can I ignore the dev dependencies of the package as well as vendor dev dependencies?
composer archive
is likely not to help you, because this command creates an archive of a defined version of a package.
You probably want to upload the whole working application, and not only one package. You should create a little script that will create the archive file for you, which should do:
composer install --no-dev
to install all required dependencies without dev-dependencies.git
folder, and other stuffHere is a pkg
bash script I created to bundle with composer archive
, but without the development dependencies. It restores the env back to the original state (assuming you want dev dependencies installed).
I still haven't found another way, even though this is years old. This worked reasonably well for packaging a private wordpress plugin.
#!/usr/bin/env bash
set -uo pipefail
rm -f *.zip || true
composer update --no-dev
composer archive --format=zip
composer update
Also worth noting, you can include/exclude files during the archive command via a block in the composer.json
:
"archive": {
"exclude": [
".*",
"pkg",
"README.md",
"bin/",
"composer.*",
"phpunit.*",
"/resources",
"tests/",
]
}
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