Skip to content

Commit 769d34d

Browse files
committed
chore(tooling): configure static analysis, testing, and dev environment
This commit establishes the comprehensive quality assurance pipeline and developer environment for the devkit. - Adds configuration for PHPCS, Infection (mutation testing), and PHPBench. - Adds recommended VSCode extensions, settings, and launch configurations. - Adds a global .editorconfig file for consistent formatting. - Updates Makefiles (local, qa, pipeline) to integrate the new tools. - Updates PHPStan, PHPUnit, and PHP-CS-Fixer configurations. - Removes the unused Rector configuration file. - Fixes source code (UserProfile, UserId) to comply with stricter PHPStan static analysis rules.
1 parent 55629c9 commit 769d34d

35 files changed

+2571
-1030
lines changed

.editorconfig

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# EditorConfig - Preserves premium comment formatting
2+
# https://editorconfig.org
3+
4+
root = true
5+
6+
[*]
7+
charset = utf-8
8+
end_of_line = lf
9+
insert_final_newline = true
10+
trim_trailing_whitespace = true
11+
indent_style = space
12+
indent_size = 4
13+
14+
[*.php]
15+
indent_style = space
16+
indent_size = 4
17+
max_line_length = 120
18+
19+
# Preserves spaces in comments (no trim)
20+
[*.php]
21+
trim_trailing_whitespace = false
22+
23+
[*.{yml,yaml}]
24+
indent_size = 2
25+
26+
[*.{json,json5}]
27+
indent_size = 2
28+
29+
[*.{md,markdown}]
30+
trim_trailing_whitespace = false
31+
max_line_length = off
32+
33+
[composer.json]
34+
indent_size = 4
35+
36+
[{package.json,*.yml,*.yaml}]
37+
indent_size = 2

.env

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
# ==============================================================================
2+
# KaririCode DevKit - Environment Configuration
3+
# ==============================================================================
4+
# Professional environment variables for Docker Compose
5+
# Copy to .env and customize: cp .env.example .env
6+
# ==============================================================================
7+
8+
# ==============================================================================
9+
# APPLICATION
10+
# ==============================================================================
11+
APP_NAME=kariricode-devkit
12+
APP_ENV=development
13+
APP_DEBUG=true
14+
APP_SECRET=change-me-in-production
15+
APP_VERSION=dev
16+
SYMFONY_ENV=dev
17+
18+
# ==============================================================================
19+
# DOCKER & SYSTEM
20+
# ==============================================================================
21+
# User/Group IDs (match host user for volume permissions)
22+
# Note: PHP container runs as root internally but processes run as www-data
23+
UID=1000
24+
GID=1000
25+
26+
# Timezone
27+
TZ=UTC
28+
29+
# Volume consistency (macOS performance)
30+
VOLUME_CONSISTENCY=cached
31+
32+
# ==============================================================================
33+
# PORTS
34+
# ==============================================================================
35+
APP_PORT=8089
36+
REDIS_PORT=6379
37+
MEMCACHED_PORT=11211
38+
39+
# ==============================================================================
40+
# PHP SERVICE (kariricode/php-api-stack)
41+
# ==============================================================================
42+
PHP_STACK_VERSION=dev
43+
44+
# PHP Configuration
45+
PHP_MEMORY_LIMIT=2G
46+
PHP_MAX_EXECUTION_TIME=300
47+
PHP_UPLOAD_MAX_FILESIZE=50M
48+
PHP_POST_MAX_SIZE=50M
49+
50+
# Resource Limits
51+
PHP_CPU_LIMIT=2.0
52+
PHP_CPU_RESERVATION=0.5
53+
PHP_MEMORY_RESERVATION=512M
54+
55+
# OPcache
56+
OPCACHE_ENABLE=1
57+
OPCACHE_VALIDATE_TIMESTAMPS=1
58+
OPCACHE_REVALIDATE_FREQ=2
59+
60+
# PHP-FPM Configuration
61+
PHP_FPM_PM=dynamic
62+
PHP_FPM_PM_MAX_CHILDREN=50
63+
PHP_FPM_PM_START_SERVERS=5
64+
PHP_FPM_PM_MIN_SPARE_SERVERS=5
65+
PHP_FPM_PM_MAX_SPARE_SERVERS=10
66+
PHP_FPM_PM_MAX_REQUESTS=500
67+
68+
# ==============================================================================
69+
# XDEBUG
70+
# ==============================================================================
71+
XDEBUG_MODE=off
72+
XDEBUG_CLIENT_HOST=host.docker.internal
73+
XDEBUG_CLIENT_PORT=9003
74+
XDEBUG_SESSION=PHPSTORM
75+
76+
# ==============================================================================
77+
# SESSION HANDLER
78+
# ==============================================================================
79+
# Session storage: files (local) or redis (distributed)
80+
SESSION_SAVE_HANDLER=files
81+
SESSION_SAVE_PATH=/tmp
82+
83+
# ==============================================================================
84+
# REDIS (Internal - Inside PHP Container)
85+
# ==============================================================================
86+
# Redis runs internally at 127.0.0.1:6379 inside PHP container
87+
REDIS_HOST=127.0.0.1
88+
REDIS_PORT_INTERNAL=6379
89+
REDIS_PASSWORD=
90+
REDIS_DB=0
91+
REDIS_TIMEOUT=5
92+
REDIS_LOG_FILE=/var/log/redis.log
93+
94+
# ==============================================================================
95+
# NGINX (Internal - Inside PHP Container)
96+
# ==============================================================================
97+
NGINX_WORKER_PROCESSES=auto
98+
NGINX_WORKER_CONNECTIONS=1024
99+
NGINX_CLIENT_MAX_BODY_SIZE=100M
100+
NGINX_KEEPALIVE_TIMEOUT=65
101+
102+
# ==============================================================================
103+
# COMPOSER
104+
# ==============================================================================
105+
COMPOSER_MEMORY_LIMIT=-1
106+
COMPOSER_HOME=/root/.composer
107+
108+
# ==============================================================================
109+
# MEMCACHED (External Service)
110+
# ==============================================================================
111+
MEMCACHED_VERSION=1.6-alpine
112+
MEMCACHED_MEMORY=256
113+
MEMCACHED_MAX_CONNECTIONS=1024
114+
MEMCACHED_THREADS=4
115+
MEMCACHED_MAX_ITEM_SIZE=5m
116+
117+
# Resource Limits
118+
MEMCACHED_CPU_LIMIT=1.0
119+
MEMCACHED_CPU_RESERVATION=0.25
120+
MEMCACHED_MEMORY_TOTAL=512M
121+
MEMCACHED_MEMORY_RESERVATION=256M
122+
123+
# Health Check
124+
MEMCACHED_HEALTHCHECK_INTERVAL=10s
125+
MEMCACHED_HEALTHCHECK_TIMEOUT=5s
126+
MEMCACHED_HEALTHCHECK_RETRIES=3
127+
MEMCACHED_HEALTHCHECK_START_PERIOD=10s
128+
129+
# ==============================================================================
130+
# FEATURES
131+
# ==============================================================================
132+
DEMO_MODE=false
133+
HEALTH_CHECK_INSTALL=false
134+
135+
# ==============================================================================
136+
# NETWORK
137+
# ==============================================================================
138+
ENABLE_IPV6=false
139+
BRIDGE_NAME=kariricode0
140+
NETWORK_MTU=1500
141+
NETWORK_SUBNET=172.20.0.0/16
142+
NETWORK_GATEWAY=172.20.0.1
143+
144+
# ==============================================================================
145+
# LOGGING
146+
# ==============================================================================
147+
LOG_MAX_SIZE=10m
148+
LOG_MAX_FILE=3
149+
LOG_LEVEL=info
150+
151+
# ==============================================================================
152+
# HEALTH CHECKS
153+
# ==============================================================================
154+
HEALTHCHECK_INTERVAL=30s
155+
HEALTHCHECK_TIMEOUT=10s
156+
HEALTHCHECK_RETRIES=3
157+
HEALTHCHECK_START_PERIOD=40s
158+
159+
# ==============================================================================
160+
# TEMPORARY FILESYSTEM
161+
# ==============================================================================
162+
TMPFS_SIZE=100M
163+
164+
# ==============================================================================
165+
# TROUBLESHOOTING
166+
# ==============================================================================
167+
# Port conflicts?
168+
# - Change APP_PORT, REDIS_PORT, or MEMCACHED_PORT
169+
# - Run: make diagnose-ports
170+
# - Run: make fix-ports
171+
#
172+
# Performance issues on macOS?
173+
# - Try VOLUME_CONSISTENCY=delegated
174+
#
175+
# Permission errors?
176+
# - Note: Container runs as root, but PHP-FPM/Nginx run as www-data
177+
# - Check file ownership: ls -la
178+
#
179+
# Memory issues?
180+
# - Adjust PHP_MEMORY_LIMIT and resource limits
181+
#
182+
# Session/Redis errors?
183+
# - Use SESSION_SAVE_HANDLER=files for development
184+
# - Use SESSION_SAVE_HANDLER=redis for distributed sessions
185+
#
186+
# PHP-FPM crashes?
187+
# - Check logs: make logs SERVICE=php
188+
# - Verify config: docker compose config
189+
#
190+
# Run diagnostics:
191+
# - make env-check # Validate .env file
192+
# - make diagnose-ports # Check port conflicts
193+
# - make docker-info # Docker environment info
194+
# - make status # Service status
195+
# - make health # Health checks
196+
# ==============================================================================
197+
198+
# ==============================================================================
199+
# PRODUCTION NOTES
200+
# ==============================================================================
201+
# For production deployment:
202+
# 1. Change APP_ENV=production
203+
# 2. Set APP_DEBUG=false
204+
# 3. Generate strong APP_SECRET: openssl rand -hex 32
205+
# 4. Set XDEBUG_MODE=off
206+
# 5. Set OPCACHE_VALIDATE_TIMESTAMPS=0
207+
# 6. Use SESSION_SAVE_HANDLER=redis with password
208+
# 7. Set proper resource limits
209+
# 8. Enable HTTPS/SSL termination
210+
# 9. Use managed Redis/Memcached services
211+
# 10. Implement proper backup strategy
212+
# ==============================================================================

0 commit comments

Comments
 (0)