PHP 8.5: CLI: php --ini=diff
to output non-default INI directives
The PHP CLI executable in PHP 8.5 supports a new php --ini=diff
command-line flag, which lists INI directives that differ from the built-in default values.
This provides a quick way to identify changed INI values, and can be especially useful in error reports that should contain the potential INI settings that might caused the issue.
PHP continues to support the php --ini
CLI option, which lists information about the loaded INI files.
Calling php --help
shows the help text for the new feature:
php --help
Usage: php [options] [-f] <file> [--] [args...]
php [options] -r <code> [--] [args...]
...
--ini Show configuration file names
+ --ini=diff Show INI entries that differ from the built-in default
...
New php --ini=diff
CLI flag
Calling PHP 8.5 and later php
executable with --ini=diff
option prints all INI directives that are different from the built-in default values.
php --ini=diff
Non-default INI settings:
html_errors: "1" -> "0"
implicit_flush: "0" -> "1"
max_execution_time: "30" -> "0"
Note that there is no option to fetch these entries in a machine-friendly format as this is meant to be mostly troubleshooting purposes.
Using --ini=diff
with other configuration options
PHP CLI offers a few CLI options to fine-tune PHP INI directives.
php -n
: No configuration (ini) files will be usedphp -c example.ini
: Look for aphp.ini
in the given directory or use the specified INI files.php -d foo=bar
: Directly set configuration options.
The new --ini=diff
option works well with all of the INI-related CLI options above.
For example, if the date.timezone
INI directive is passed using the -d
CLI option, this change is reflected in the --ini=diff
output:
php -d date.timezone="Europe/Amsterdam" --ini=diff
Non-default INI settings:
date.timezone: "UTC" -> "Europe/Amsterdam"
html_errors: "1" -> "0"
implicit_flush: "0" -> "1"
max_execution_time: "30" -> "0"
Backward Compatibility Impact
php --ini=diff
is a new CLI option added in PHP 8.5, and it does not cause any backward-compatibility issues.
Calling php --ini=diff
on older PHP CLI executables does not cause any error, but the output will be the same as php --ini
.