Welcome Guest, Not a member yet? Register   Sign In
Call to undefined function CodeIgniter\Config\putenv()
#1

In production environment. I got this issue. The hosting provider had blocked the putenv() function for security reason.

Quote:Fatal error: Uncaught Error: Call to undefined function CodeIgniter\Config\putenv() in /www/wwwroot/idp/printerp_api/vendor/codeigniter4/framework/system/Config/DotEnv.php:92 Stack trace: #0 /www/wwwroot/idp/printerp_api/vendor/codeigniter4/framework/system/Config/DotEnv.php(77): CodeIgniter\Config\DotEnv->setVariable() #1 /www/wwwroot/idp/printerp_api/vendor/codeigniter4/framework/system/Config/DotEnv.php(43): CodeIgniter\Config\DotEnv->parse() #2 /www/wwwroot/idp/printerp_api/public/index.php(30): CodeIgniter\Config\DotEnv->load() #3 {main} thrown in /www/wwwroot/idp/printerp_api/vendor/codeigniter4/framework/system/Config/DotEnv.php on line 92

When i'm looking for the source of DotEnv.php, it didn't check the function exists or not.

PHP Code:
protected function setVariable(string $namestring $value '')
{
    if (! getenv($nametrue)) {
        putenv("{$name}={$value}"); // <== Here's the error occurred.
    }

    if (empty($_ENV[$name])) {
        $_ENV[$name] = $value;
    }

    if (empty($_SERVER[$name])) {
        $_SERVER[$name] = $value;
    }


So i have to remark the 92nd line of codes.
Reply
#2

Please, I'm begging you, begging you. How did you solved it?
Reply
#3

Try to add this in app/Common.php:
PHP Code:
if (! function_exists('putenv')) {
    function putenv(string $assignment) {}

Reply




Theme © iAndrew 2016 - Forum software by © MyBB