Error 500 - CLI.php - Use of undefined constant STDOUT - 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 500 - CLI.php - Use of undefined constant STDOUT (/showthread.php?tid=79800) Pages:
1
2
|
Error 500 - CLI.php - Use of undefined constant STDOUT - Toximik - 07-28-2021 Hi, i have just installed fresh CI4 using composer (composer create-project codeigniter4/appstarter test) and set baseURL i get this error: Code: Fatal error: Uncaught ErrorException: Use of undefined constant STDOUT - assumed 'STDOUT' (this will throw an Error in a future version of PHP) in /var/www/html/test/vendor/codeigniter4/framework/system/CLI/CLI.php:162 Stack trace: #0 /var/www/html/test/vendor/codeigniter4/framework/system/CLI/CLI.php(162): CodeIgniter\Debug\Exceptions->errorHandler(2, 'Use of undefine...', '/var/www/html/t...', 162, Array) #1 /var/www/html/test/vendor/codeigniter4/framework/system/CLI/CLI.php(1184): CodeIgniter\CLI\CLI::init() #2 /var/www/html/test/vendor/codeigniter4/framework/system/Autoloader/Autoloader.php(300): include_once('/var/www/html/t...') #3 /var/www/html/test/vendor/codeigniter4/framework/system/Autoloader/Autoloader.php(273): CodeIgniter\Autoloader\Autoloader->includeFile('/var/www/html/t...') #4 /var/www/html/test/vendor/codeigniter4/framework/system/Autoloader/Autoloader.php(247): CodeIgniter\Autoloader\Autoloader->loadInNamespace('CodeIgniter\\CLI...') #5 [internal function]: CodeIgniter\Autoloader\Autoloader->loadClass( in /var/www/html/test/vendor/codeigniter4/framework/system/CLI/CLI.php on line 162 I'm using DDEV with Docker to host it, webserver image using NGINX and PHP 7.4. I haven't expirenced any problems so far using this image in other projects. I have alredy tried fresh install, different version of PHP and nothing helped. RE: Error 500 - CLI.php - Use of undefined constant STDOUT - Taras - 08-14-2021 Hi, have you found solution? Same here after updating from the v4.1.1. When I run "php spark serve" it works fine. RE: Error 500 - CLI.php - Use of undefined constant STDOUT - Taras - 08-15-2021 After some investigation I found that there are changes in system/Common.php for is_cli() method that cause current issue. It's identified as CLI in condition: PHP Code: if (stristr(PHP_SAPI, 'cgi') && getenv('TERM')) because PHP_SAPI equals to fpm-fcgi and TERM variable equals to xterm. Is this correct behavior? How this should be fixed? (I am using docker with php-fpm and nginx.) RE: Error 500 - CLI.php - Use of undefined constant STDOUT - InsiteFX - 08-15-2021 Your getting the errors because STDOUT is not defined, which could be your environment. You can try adding these constants to see if it will work. PHP Code: if(!defined('STDIN')) define('STDIN', fopen('php://stdin', 'rb')); Try that. RE: Error 500 - CLI.php - Use of undefined constant STDOUT - Taras - 08-16-2021 As I understand, the problem appears because request from browser incorrectly identified as CLI one. This is why those constants are undefined. @InsiteFX, I tried to put those definitions. Now I receive blank page (with no errors). My solution is to put older version of is_cli() into app/Common.php, overriding updated one from system/Common.php. (I've taken it from https://github.com/codeigniter4/CodeIgniter4/blob/096f9720552ba8a572acf65f386184cc4200e6b5/system/Common.php.) PHP Code: function is_cli(): bool Now pages open fine. RE: Error 500 - CLI.php - Use of undefined constant STDOUT - paulbalandan - 08-18-2021 Hi! Your issue, along with some others, has a fix already in the provisional 4.2 branch. RE: Error 500 - CLI.php - Use of undefined constant STDOUT - Taras - 08-19-2021 (08-18-2021, 09:00 PM)paulbalandan Wrote: Hi! Thanks, that code works fine too. RE: Error 500 - CLI.php - Use of undefined constant STDOUT - fagnerdin - 10-14-2021 [quote pid="389403" dateline="1629345651"] Quote:Hi! [/quote] Hi, folks! Please, where's 4.2 branch? RE: Error 500 - CLI.php - Use of undefined constant STDOUT - InsiteFX - 10-15-2021 You can always get the latest version of CodeIgniter from the GitHub Developer Page. CodeIgniter 4 - Developer Version. CodeIgniter 4 web framework RE: Error 500 - CLI.php - Use of undefined constant STDOUT - fagnerdin - 10-15-2021 By the way, I discovered branch 4.2: "codeigniter4:4.2 - Make CLI detection as independent as possible from interface #4844" Looks like this isn't accessible branch. I was facing this issue in a Docker container, I solved it using a ready-made solution from another professional (a Dockerfile). Thank you for your help. |