SyntaxStudy
Sign Up
PHP Beginner 3 min read

composer.json Structure

composer.json

The composer.json file describes your project: name, dependencies, autoloading, and scripts.

Example
{
  "name": "myapp/app",
  "require": { "php": "^8.2", "guzzlehttp/guzzle": "^7.0" },
  "require-dev": { "phpunit/phpunit": "^10.0" },
  "autoload": { "psr-4": { "App\\": "src/" } },
  "autoload-dev": { "psr-4": { "Tests\\": "tests/" } },
  "scripts": { "test": "phpunit", "lint": "php-cs-fixer fix --dry-run" }
}
Pro Tip

The autoload section maps namespace prefixes to directories — run composer dump-autoload after changes.