composer.json
Understand and configure composer.json so Discloud can install your PHP dependencies automatically.
🗂 What is composer.json
?
composer.json
?composer.json
declares your project's metadata, required packages, autoload rules, and optional scripts. When present at the root of the archive you upload, Discloud installs the dependencies defined inside using Composer.
🛠 Creating composer.json
composer.json
1
Generate interactively:
composer init
2
Or create a minimal file manually:
{
"name": "example/app",
"type": "project",
"require": {
"guzzlehttp/guzzle": "^7.9"
},
"autoload": {
"psr-4": { "App\\\\": "src/" }
}
}
3
Then install:
composer install
📦 Adding / Updating Dependencies
Install new package:
composer require ramsey/uuid
Update one package:
composer update ramsey/uuid
Update all (may change versions broadly):
composer update
📄 Lock File (composer.lock
)
composer.lock
)Commit composer.lock
so deployments reproduce the exact dependency versions. If absent, latest matching versions are resolved during install.
🧰 Common Commands Reference
# Init project
composer init
# Install deps
composer install
# Remove package
composer remove vendor/pkg
# Optimize autoload
composer dump-autoload --optimize
# Run script
composer run-script <name>
# Show outdated
composer outdated
Last updated