Using getenv() is generally preferred over $_ENV because getenv() always reads directly from the environment variables, regardless of PHP's variables_order setting.
This provides more consistent and reliable access to environment variables, especially in various server configurations, and helps avoid potential security issues where $_ENV might inadvertently expose sensitive data.
Because of that, php servers disabled ENV super global in php.ini settings (including docker images) and your code is failing on that by using method 'createFromEnv()'.