Dokumentation » Anwendungen » PHP Quality Tools
PHP Quality & Security Tools
Statische Analyse, Code-Style-Prüfung und Security-Scanning für PHP. Stellt Codequalität, PSR-12 Konformität, Typsicherheit und OWASP-Compliance sicher.
PHPStan 2.1.33 + Strict Rules
PHP-CS-Fixer 3.92.3
Semgrep 1.146.0 (OWASP Scanner)
Composer Audit CVE-Check für Dependencies
Installation /opt/php-tools/
Script /opt/scripts/php-check.sh
Verwendung
# Prüfung (dev)
/opt/scripts/php-check.sh
# Prüfung (beliebiges Projekt)
/opt/scripts/php-check.sh /pfad/zum/projekt
# Mit automatischer Korrektur
/opt/scripts/php-check.sh /pfad/zum/projekt --fix
PHPStan + Strict Rules
Statische Analyse für Typsicherheit, Null-Safety und Bug-Erkennung.
Level 5 (von 10)
Strict Rules phpstan-strict-rules 2.0.7
Konfig /opt/php-tools/phpstan.neon
Scope src/, app/ (ohne View/)
PHP-CS-Fixer
Automatische Code-Formatierung nach PSR-12 Standard.
Standard PSR-12
Konfig /opt/php-tools/.php-cs-fixer.php
Regeln
PSR-12 Basis
Short Array Syntax []
Single Quotes, Trailing Commas
Sortierte Imports, keine ungenutzten
Semgrep (OWASP Security)
Pattern-basierter Security Scanner für OWASP-Vulnerabilities.
Version 1.146.0
Konfig /opt/php-tools/semgrep-security.yml
Installation /root/.local/bin/semgrep (pipx)
Erkannte Vulnerabilities
Typ OWASP CWE
Cross-Site Scripting (XSS) A03:2021 CWE-79
XML External Entity (XXE) A05:2021 CWE-611
Server-Side Template Injection (SSTI) A03:2021 CWE-1336
Server-Side Request Forgery (SSRF) A10:2021 CWE-918
Cross-Site Request Forgery (CSRF) A01:2021 CWE-352
Command Injection A03:2021 CWE-78
SQL Injection A03:2021 CWE-89
File Inclusion A03:2021 CWE-98
Path Traversal A01:2021 CWE-22
Eval/Code Injection A03:2021 CWE-94
Unsafe Deserialization A08:2021 CWE-502
Header Injection A03:2021 CWE-113
LDAP Injection A03:2021 CWE-90
Direkt ausführen
/root/.local/bin/semgrep scan \
--config /opt/php-tools/semgrep-security.yml \
src app
Composer Audit
Prüft Composer-Dependencies auf bekannte CVEs.
composer audit --working-dir=/var/www/dev.campus.systemische-tools.de
Automatisierung
PostToolUse Hook (nach jeder Dateiänderung)
Trigger Edit, Write auf *.php
Script /opt/scripts/php-style-hook.py
Prüfung PHP-CS-Fixer (nur Style)
Verhalten Warnung, kein Block
Pre-Sync Check (vor Deployment)
Trigger /opt/scripts/sync-dev-prod.sh
Prüfung PHPStan + PHP-CS-Fixer + Composer Audit + Semgrep
Verhalten Blockiert bei Fehlern
Prinzipien & Prüfungen
Prinzip Bedeutung Tool
PSR-12 Code Style PHP-CS-Fixer
Type Safety Typsicherheit PHPStan + Strict Rules
OWASP Security Vulnerabilities Semgrep
CVE Dependency Vulnerabilities Composer Audit
DRY/KISS/YAGNI Clean Code Manuell / Review