Find the php.ini File Actually Loaded by PHP CLI

Last updated: December 1, 2026.

Run php --ini with the same executable and shell environment as the failing command. The output distinguishes the primary configuration PHP loaded from the additional files it scanned.

php -v
php --ini
php -n --ini

Read the loaded and scanned paths

Look for Loaded Configuration File first. If it says (none), PHP did not load a primary file. The subsequent lines show any configured scan directory and which additional files were parsed. A scan directory alone does not prove that any of its files were read.

The -n comparison starts PHP without ini files. If the issue disappears under that run, inspect the regular ini output before deciding what to change. Some extensions are compiled in, while others are loaded by ini files. Skipping the files can therefore remove an extension needed by the application.

Isolate one runtime and one setting

If your machine has several PHP installations, use the executable’s full path or check the command resolution in your shell. The optional -c flag lets CLI PHP select a specific primary ini file or directory. PHP can still scan additional ini files, so check the --ini output after applying it. PHPRC can affect the primary file search, and PHP_INI_SCAN_DIR can redirect the additional-file scan.

After identifying a likely override, check the effective value with ini_get() in the same invocation. If a web request behaves differently from the CLI command, inspect it within the actual server runtime. php_ini_loaded_file() reports the loaded file for the running process. Send diagnostics to a protected log or use a local environment to avoid exposing filesystem paths publicly.

Documentation

Related guides

Sergey Kornilov

Sergey Kornilov