Skip to content

Commit 2d6a71d

Browse files
committed
Add environment-specific PHP configuration files
This commit introduces dedicated PHP configuration files for development and production environments: - Add php.dev.ini with developer-friendly settings: * Full error reporting and display * Xdebug enabled with comprehensive debugging features * Generous memory limits and execution times * Development-oriented opcache settings with timestamp validation - Add php.prod.ini with production-optimized settings: * Disabled error display (but continued logging) * Security hardening with disabled functions * Performance tuning with aggressive opcache settings * Memory and execution limits optimized for efficiency * JIT compilation enabled for PHP 8+ * Xdebug completely disabled This approach provides better separation of concerns by moving PHP configuration from environment variables to dedicated configuration files, offering more fine-grained control over PHP behavior in different environments.
1 parent f446847 commit 2d6a71d

File tree

3 files changed

+138
-52
lines changed

3 files changed

+138
-52
lines changed

etc/php/php.dev.ini

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2+
; PHP Development Environment Configuration ;
3+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4+
5+
[PHP]
6+
; Timezone setting
7+
date.timezone = UTC
8+
9+
; Error reporting settings - Development focused
10+
display_errors = On
11+
display_startup_errors = On
12+
error_reporting = E_ALL
13+
log_errors = On
14+
error_log = /var/log/php/php_errors.log
15+
report_memleaks = On
16+
html_errors = On
17+
18+
; Memory and execution limits for development
19+
memory_limit = 256M
20+
max_execution_time = 120
21+
max_input_time = 120
22+
post_max_size = 50M
23+
upload_max_filesize = 50M
24+
25+
; Development features
26+
expose_php = On
27+
assert.active = On
28+
zend.assertions = 1
29+
30+
; Session settings
31+
session.cache_limiter = nocache
32+
session.use_strict_mode = 1
33+
session.cookie_httponly = 1
34+
session.cookie_secure = 1
35+
session.cookie_samesite = "Lax"
36+
session.gc_maxlifetime = 7200
37+
38+
; Opcache settings for development
39+
opcache.enable = 1
40+
opcache.memory_consumption = 128
41+
opcache.interned_strings_buffer = 8
42+
opcache.max_accelerated_files = 10000
43+
opcache.revalidate_freq = 0
44+
opcache.validate_timestamps = 1
45+
opcache.fast_shutdown = 1
46+
opcache.enable_cli = 1
47+
48+
; Xdebug 3 configuration
49+
[Xdebug]
50+
xdebug.mode = debug,develop,coverage
51+
xdebug.start_with_request = yes
52+
xdebug.client_host = host.docker.internal
53+
xdebug.client_port = 9003
54+
xdebug.log = /tmp/xdebug.log
55+
xdebug.log_level = 3
56+
xdebug.idekey = VSCODE
57+
;xdebug.idekey = PHPSTORM
58+
59+
; Development utilities
60+
xdebug.cli_color = 1
61+
xdebug.var_display_max_depth = 8
62+
xdebug.var_display_max_children = 256
63+
xdebug.var_display_max_data = 1024
64+
xdebug.max_nesting_level = 256
65+
xdebug.show_error_trace = 1
66+
xdebug.file_link_format = vscode://file/%f:%l

etc/php/php.ini

Lines changed: 0 additions & 52 deletions
This file was deleted.

etc/php/php.prod.ini

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2+
; PHP Production Environment Configuration ;
3+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
4+
5+
[PHP]
6+
; Timezone setting
7+
date.timezone = UTC
8+
9+
; Error reporting settings - Production focused
10+
display_errors = Off
11+
display_startup_errors = Off
12+
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
13+
log_errors = On
14+
error_log = /var/log/php/php_errors.log
15+
ignore_repeated_errors = On
16+
report_memleaks = Off
17+
html_errors = Off
18+
19+
; Security settings
20+
expose_php = Off
21+
disable_functions = system,exec,shell_exec,passthru,proc_open,popen,show_source,phpinfo
22+
23+
; Memory and execution limits - Optimized for production
24+
memory_limit = 128M
25+
max_execution_time = 60
26+
max_input_time = 60
27+
post_max_size = 20M
28+
upload_max_filesize = 20M
29+
30+
; Request handling
31+
max_input_vars = 2000
32+
realpath_cache_size = 4M
33+
realpath_cache_ttl = 600
34+
35+
; Session settings - Secure for production
36+
session.use_strict_mode = 1
37+
session.cookie_httponly = 1
38+
session.cookie_secure = 1
39+
session.cookie_samesite = "Lax"
40+
session.gc_maxlifetime = 3600
41+
session.use_only_cookies = 1
42+
session.gc_probability = 1
43+
session.gc_divisor = 100
44+
45+
; Performance optimizations
46+
zlib.output_compression = On
47+
zlib.output_compression_level = 4
48+
implicit_flush = Off
49+
50+
; Opcache settings - Production optimized
51+
opcache.enable = 1
52+
opcache.memory_consumption = 256
53+
opcache.interned_strings_buffer = 16
54+
opcache.max_accelerated_files = 20000
55+
opcache.revalidate_freq = 60
56+
opcache.validate_timestamps = 0
57+
opcache.fast_shutdown = 1
58+
opcache.enable_file_override = 1
59+
opcache.save_comments = 1
60+
opcache.enable_cli = 0
61+
opcache.huge_code_pages = 1
62+
opcache.jit = 1255
63+
opcache.jit_buffer_size = 128M
64+
65+
; File handling
66+
allow_url_fopen = Off
67+
file_uploads = On
68+
default_socket_timeout = 30
69+
70+
; Xdebug is disabled in production
71+
[Xdebug]
72+
xdebug.mode = off

0 commit comments

Comments
 (0)