PHP - putenv() function not working

My code has been working for many months at this point; but suddenly, I stopped being able to load calendars using the Google API, despite the fact that I had changed nothing. After a great deal of troubleshooting, I came to the conclusion that the putenv() function is not working. putenv() is supposed to return true or false upon success or failure; however, when I set

$success = putenv('GOOGLE_APPLICATION_CREDENTIALS=/path/to/credentials.json');
var_dump($success);

it printed a NULL value. This makes me suspect that putenv() was disabled in php.ini, or something similar. Was this intentional or a mistake? If the latter, please fix; if the former, please tell me.

@teodor @ckhawand any advice for him?

Are you sure it is not an issue from google’s end?

I’m also dealing with that same problem.
This is not an issue in google’s end because server gives warning:

Warning: putenv() has been disabled for security reasons

Hi all!

What are your website addresses?

I’m not getting the same message as @philtu, but I’m still certain it’s not an issue on Google’s end since a) that code I wrote above should still have displayed either a true or false value for $success instead of NULL, and b) manually inserting the json file path inside the API code instead of using the putenv() function allows the site to function normally. But of course that’s not a real solution, just a stopgap.

Mine is: http://philtu.000webhostapp.com/

(test script: http://philtu.000webhostapp.com/test.php

<?php putenv('foo=bar');

)

lobsang-jampa-rinpoche.000webhostapp.com

But again, I went into the API and edited Google’s code directly to get around the error, so you won’t see the issue there.

I don’t get an error at the putenv() line; I get the error when the code later attempts to use getenv() to retrieve the environment variable and gets nothing in return. Therefore it exits out of the method and throws an exception that tells me it can’t obtain credentials from Google, which is why it took me so long to figure out what was causing the problem in the first place.