platformsh/config-reader-php

Broken on PHP 8.0+

Closed this issue · 1 comments

Using this library for a Laraval application (Bookstack) and they just dropped support for PHP 7.4. Upon updating to PHP 8 (8.2 specifically), the application was throwing this error:

Using the code snippet:

$config = new \Platformsh\ConfigReader\Config();

if($config->hasRelationship('database')){
    foreach($config->variables as $k => $v) {
        putenv("$k=$v");
    }
}

I get the following error:

Fatal error: Uncaught InvalidArgumentException: No such variable defined: variables in /app/vendor/platformsh/config-reader/src/Config.php:559 Stack trace: #0 /app/public/index.php(40): Platformsh\ConfigReader\Config->__get('variables') #1 {main} thrown in /app/vendor/platformsh/config-reader/src/Config.php on line 559

gilzow commented

I believe the error is related to variables being a method ($config->variables()) and not a property ($config->variables) as seen above. I don't believe this is related to the PHP version as I'm using it on several projects that are on PHP 8.1.

Do you remember where you got the posted snippet?