Convert php.ini Configuration to JSON
Convert PHP's php.ini configuration file to JSON format. Covers PHP-specific values like memory_limit, error_reporting, and extension directives.
Detailed Explanation
php.ini to JSON
PHP's php.ini is one of the most widely used INI-format configuration files. It controls PHP's runtime behavior including memory limits, error handling, file uploads, session management, and extension loading.
Example php.ini
[PHP]
engine = On
short_open_tag = Off
precision = 14
output_buffering = 4096
max_execution_time = 30
max_input_time = 60
memory_limit = 256M
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = Off
log_errors = On
error_log = /var/log/php_errors.log
upload_max_filesize = 50M
post_max_size = 55M
[Date]
date.timezone = America/New_York
[Session]
session.save_handler = files
session.gc_maxlifetime = 1440
session.cookie_secure = 1
session.cookie_httponly = 1
Generated JSON
{
"PHP": {
"engine": true,
"short_open_tag": false,
"precision": 14,
"output_buffering": 4096,
"max_execution_time": 30,
"max_input_time": 60,
"memory_limit": "256M",
"error_reporting": "E_ALL & ~E_DEPRECATED",
"display_errors": false,
"log_errors": true,
"error_log": "/var/log/php_errors.log",
"upload_max_filesize": "50M",
"post_max_size": "55M"
},
"Date": {
"date.timezone": "America/New_York"
},
"Session": {
"session.save_handler": "files",
"session.gc_maxlifetime": 1440,
"session.cookie_secure": 1,
"session.cookie_httponly": 1
}
}
PHP-Specific Considerations
- On/Off values: PHP uses
OnandOff(case-insensitive) as boolean equivalents, which are coerced totrue/false - Memory notation: Values like
256M,50Mremain as strings because they contain unit suffixes - Dot-prefixed keys: Keys like
session.cookie_secureare NOT interpreted as nested sections — they are treated as literal key names within their section - PHP constants: Values like
E_ALL & ~E_DEPRECATEDremain as strings since they are PHP-specific expressions - Disabled directives: Some php.ini files use commented-out lines with
;to show available but disabled options
Use Case
Auditing PHP configuration across multiple servers by converting each server's php.ini to JSON, then using tools like jq or a script to diff the configurations and identify discrepancies in security or performance settings.
Try It — INI \u2194 JSON Converter
Related Topics
Convert MySQL my.cnf Configuration to JSON
Common Files
Convert INI Sections to Nested JSON Objects
Basic Conversion
INI Boolean Values to JSON: true/false, yes/no, on/off
Sections
Preserving INI Comments During JSON Conversion
Comments & Edge Cases
Handling Inline Comments in INI Files
Comments & Edge Cases