Composer tooling

From AratKruglik/claude-sdlc · View interactive version

Composer tooling is an AI agent skill from the GitHub repository AratKruglik/claude-sdlc. Composer conventions for any PHP project: dependency management, version constraints, PSR-4 autoloading, scripts, platform requirements, and the composer.json vs composer.lock contract. Stack-agnostic — referenced by every PHP plugin in the marketplace. Use this skill to: - Read composer.json to det

How to use this skill

Skill file

Composer Tooling (stack-agnostic)

Composer is the dependency manager and autoloader entry point for every modern PHP project. Read composer.json before doing anything else — it tells you the PHP version, the framework, and the available packages.

Project detection

cat composer.json                 # PHP version (require.php), framework, scripts
test -f composer.lock && echo "locked"   # lockfile present → reproducible installs

Key fields to read:

composer.json vs composer.lock

| Command | Effect |

|---|---|

| composer install | Installs the exact versions from composer.lock. Use in CI/deploy. |

| composer update <pkg> | Re-resolves the named package, rewrites the lock. Use deliberately. |

| composer require <pkg> | Adds to composer.json + updates the lock for that package. |

| composer require --dev <pkg> | Same, into require-dev. |

Never hand-edit composer.lock. Never run a bare composer update (updates everything) as part of a focused feature change.

Version constraints

{
  "require": {
    "php": "^8.2",              // >=8.2.0 <9.0.0 — recommended for libraries/apps
    "guzzlehttp/guzzle": "^7.8" // caret: compatible up to the next major
  }
}

Adding a dependency — checklist

  1. Confirm it is not already provided transitively (composer why <pkg> / check existing require).
  2. Choose require (runtime) vs require-dev (tools/tests) correctly.
  3. Use a caret constraint unless the project convention says otherwise.
  4. Run composer require <pkg> so the lockfile updates atomically.
  5. Verify nothing else moved: review the composer.lock diff — only the new package and its deps should change.

PSR-4 autoloading

{
  "autoload": {
    "psr-4": {
      "App\\": "src/"
    }
  },
  "autoload-dev": {
    "psr-4": {
      "App\\Tests\\": "tests/"
    }
  }
}

Scripts

{
  "scripts": {
    "test": "phpunit",
    "stan": "phpstan analyse",
    "cs": "php-cs-fixer fix"
  }
}

Run via composer test, composer stan. Prefer existing scripts over invoking the binary directly — they encode the project's intended flags. Discover them with composer run-script --list.

Platform requirements

{
  "config": {
    "platform": {
      "php": "8.2.0"
    }
  }
}

config.platform.php tells Composer which PHP version to resolve against, independent of the local CLI version — keep it aligned with the production runtime so the lockfile is deployable.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.