Composer in CI
Optimise Composer for CI: cache the vendor directory, use no-interaction flags, and audit for vulnerabilities on every build.
Optimise Composer for CI: cache the vendor directory, use no-interaction flags, and audit for vulnerabilities on every build.
# GitHub Actions example
- name: Cache Composer dependencies
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-composer-${{ hashFiles("composer.lock") }}
- name: Install dependencies
run: composer install --no-dev --no-interaction --prefer-dist --optimize-autoloader
- name: Security audit
run: composer audit
Cache based on composer.lock hash — cache invalidates automatically when dependencies change.