CLI and FPM may load different PHP configurations, extensions and environment variables despite running the same source code.
What It Does
Show the CLI SAPI and active configuration. Inspect FPM or the web SAPI using a private development route.
Requirements and Compatibility
Use a supported PHP runtime and install any third-party tool or extension explicitly shown in the examples. Commands should be run from the project root unless stated otherwise.
Syntax, Inputs and Results
The examples separate configuration, the smallest working operation and a realistic follow-up task. Adapt file paths and dependency versions to your own project.
Example 1: Basic Use
Show the CLI SAPI and active configuration.
php --ini
php -r 'echo PHP_SAPI, " | " , php_ini_loaded_file(), PHP_EOL;'
Example 2: Another Case
Inspect FPM or the web SAPI using a private development route.
<?php
header('Content-Type: text/plain');
echo PHP_SAPI, PHP_EOL;
echo php_ini_loaded_file() ?: 'No ini';
echo PHP_EOL, getcwd();
Practical Example
Compare extensions and resource limits with the web output.
php -m | sort
php -r 'echo ini_get("memory_limit"), PHP_EOL;'
For production, apply the compatibility and edge-case limits described below.
Important Behavior and Edge Cases
Check each active SAPI separately rather than assuming CLI settings control web requests.
Comparison with Related Functions and Tools
| Subject | Key difference |
|---|---|
| Step debugging vs profiling | Step debugging pauses individual statements; profiling records aggregate runtime cost. |
Common Beginner Mistakes
| Mistake | Correct approach |
|---|---|
| Enabling the debugger for every production request | Use controlled triggers and disable development modes in production. |
| Skipping the prerequisite of this specific workflow | Install or configure the named tool and confirm the example can actually run. |
| Ignoring edge conditions | Check each active SAPI separately rather than assuming CLI settings control web requests. |
Key Takeaways
- CLI and FPM may load different PHP configurations, extensions and environment variables despite running the same source code.
- Check each active SAPI separately rather than assuming CLI settings control web requests.
- Keep application configuration, source code and validation tests under version control.
Use these examples as a starting point, then validate the result with the actual PHP build, dependencies and inputs used by your application.