You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PHP defines STDIN, STDOUT and STDERR only in the CLI SAPI. Outside the CLI, CLI::init() defines a stand-in for STDOUT (php://output) but not for STDERR, and CLI::error() references STDERR both for its color check and for the write itself.
Steps to Reproduce
Add a route to a controller method that runs a command reporting an error, for example an unknown command name:
Serve the app with a web SAPI (php spark serve, Apache with mod_php, or PHP-FPM).
Request the route.
Expected Output
command() returns the error message as part of the command's output, the same way it returns output from CLI::write(), instead of the request ending in a fatal error.
Anything else?
Originally reported on CodeIgniter 4.1.3 with PHP 8.0.8, Apache 2.4.29 and Ubuntu 18.04.5, using a custom command that calls CLI::error(). The reporter worked around it by overriding CLI::error() to write through STDOUT when is_cli() is false.
Still reproducible on develop (b86f337). The same class of problem affects CLI::clearScreen() on Windows, which probes the STDOUT stand-in string for VT100 support, and SignalTrait::getProcessState(), which calls posix_isatty(STDIN).
Activity
MGatner commentedon Aug 17, 2021
I think @paulbalandan already fixed this on
4.2, perhaps?[-]Bug: [/-][+]Bug: Undefined constant CodeIgniter\CLI\STDERR[/+]paulbalandan commentedon Aug 17, 2021
Yes, fixed in 4.2
[-]Bug: Undefined constant CodeIgniter\CLI\STDERR[/-][+]Bug: Undefined constant `CodeIgniter\CLI\STDERR`[/+]paulbalandan commentedon Oct 9, 2026
Apparently, this issue was not fixed in
4.2🤦♂️ @tonynamy my apologies.