barryvdh/laravel-vendor-cleanup
Removes unused or redundant files from your Laravel vendor directory, keeping it lean for deployment. Cleans up docs, tests, and other cruft from installed packages to reduce upload size and speed up deploys.
vendor/. A dependency is defensible only because maintenance cost is near zero; the alternative is inlining the rules into your own deploy script and dropping a supply-chain node. With 161 stars, zero dependents, a single maintainer, and a 1.315 overall score against an opportunity score of 0.29, this is recipe-grade tooling, not a platform investment.--no-dev, --prefer-dist, optimized autoloader, .dockerignore, multistage builds, and slim base images. It should never be the headline lever or the only change in a release-engineering epic.composer install --no-dev --prefer-dist --optimize-autoloader plus a multistage Docker build. Fund that baseline first; treat vendor pruning as an increment only after the baseline is measured.vendor/ are rarely web-reachable. Do not let it inflate a security roadmap.Consider it when:
vendor/ tree, no build stage prunes it, and size or deploy time is a measured pain point with a before-number to improve.RUN step. One-off manual runs silently regress on the next composer install.Look elsewhere when:
--no-dev --prefer-dist --optimize-autoloader, measure, then decide if anything is left..dockerignore, and layer ordering dominate; pruning READMEs is a rounding error by comparison..gitattributes export-ignore solves it upstream, permanently and once.require-dev while production builds use --no-dev and you are unwilling to add a builder stage — the command simply won’t exist where you need it.Core tradeoff to accept: cleanup mutates vendor/ after Composer has recorded state. installed.json no longer matches disk, composer install may re-download packages it believes are complete, and runtime breakage can surface only in production.
For executives: A single-purpose Laravel utility that strips tests, documentation, and CI config out of vendor/ after dependency installation, shrinking the deployed artifact. Cost to adopt is hours, not sprints; the ceiling is low but so is the risk. Expected savings are single-digit to low-double-digit megabytes and seconds of deploy time — meaningful only where artifact size or upload time is a first-class constraint (Lambda, on-prem distributions, bandwidth-capped hosting). Recommendation: a contained experiment in one pipeline with before/after numbers, not a platform initiative.
For engineering: One Artisan command plus a configurable pattern list in config/vendor-cleanup.php; it reads vendor/composer/installed.json to enumerate packages. Wire it into a post-install Composer script or Docker builder stage so it runs on every build — never manually. Guard two things: cleanup is a destructive mutation, so it must be idempotent and re-applied after every install/update; and audit dependencies that read their own docs, tests, or fixtures at runtime before enabling aggressive rulesets. Ordering matters: install → clean → autoload dump / package discovery / view and route caching. Watch the availability trap — if the package is require-dev and the runtime build uses --no-dev, run it in a separate builder stage. Start with default patterns, run the full suite and a smoke deploy against the pruned artifact, then expand. Keep a one-flag disable and a tested rollback to an unpruned artifact.
For finance/ops: Frame value against concrete cost drivers — container registry storage and egress, Lambda package ceilings that force awkward workarounds, deploy duration multiplied by deploys per day, and per-deploy transfer cost on bandwidth-constrained hosts. If none of those appear on a dashboard, the right answer is “not now,” and the engineering hour is better spent on --no-dev hygiene and multistage builds, which deliver more for less operational risk.
Recommendation: Pilot in one non-critical pipeline. Instrument artifact size and deploy duration before/after, and rehearse rollback so the failure path is boring. Promote to the standard deploy script only if the delta is measurable and repeatable, and re-validate after Composer dependency updates or Laravel upgrades. Otherwise adopt the dependency-free baseline and revisit only if a hard size constraint emerges.
How can I help you explore Laravel packages today?