CodeIgniter Forums
Error: Undefined constant "CodeIgniter\CLI\STDERR" - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Error: Undefined constant "CodeIgniter\CLI\STDERR" (/showthread.php?tid=88873)



Error: Undefined constant "CodeIgniter\CLI\STDERR" - brabus - 11-24-2023

Hi, all, have been working on php spark, than i wanted to went to nginx, on first error got unwritable writable/cache, which solved by chmod 775, now I got that error: 

SYSTEMPATH/CLI/CLI.php
 at line 488
Have been looked in php.net/search engine did not found info about that const...  

New info: that was because i used: var_dump(command('logs:clear')); 

Seems I misunderstood and that function is only for CLI... Forgot i was used $migration->latest(); & cache()->clean();


RE: Error: Undefined constant "CodeIgniter\CLI\STDERR" - kenjis - 11-24-2023

I don't recommend to use CLI command via web.
But If you really want to run it, try:
Code:
--- a/system/CLI/CLI.php
+++ b/system/CLI/CLI.php
@@ -180,6 +180,7 @@ class CLI
            // we need to define STDOUT ourselves
            // For "! defined('STDOUT')" see: https://github.com/codeigniter4/CodeIgniter4/issues/7047
            define('STDOUT', 'php://output'); // @codeCoverageIgnore
+            define('STDERR', 'php://output');
        }
    }