← PHP / Laravel · Contents

PHP-100 / Beginner

Including development dependencies and test files in production deployments

A05:2021 Security Misconfiguration · CWE-489 Active Debug Code · A06:2021 (scope reduction)

Why is this a problem?

tests/, .git/ and phpunit.xml become web-accessible or increase the attack surface.

How to fix it

bash
composer install --no-dev --optimize-autoloader
rsync -a --exclude '.git' --exclude 'tests' ./ /var/www/app/
# Block .git and tests on the web server; only public is the document root

Further reading