How to use env variables inside config files #10261
-
How can I reference env variables inside My config currently looks like
phpstan-bootstrap.phprequire_once __DIR__. '/vendor/autoload.php';
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__, '.env.phpstan');
$dotenv->load(); env.phpstanCMS_PHP_STAN_PATH="C:\Users\...\phpstan\phpstan.neon"
CMS_BASE_PATH="C:\xampp\htdocs\...\..." The reason behind this is: we always execute our code on a remote system and each of my team only has a local instance of the CMS we use on our system. We include this as a PHPStorm include path and do not install the CMS again and again in each folder but everyone places the CMS in a different location. So I wanted to create the path to the local folder as an env variable. however I always get the error
I know there is similar question #8120 but I have no idea how to use a relFile |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
It's too late to do this in a bootstrap file. if you define them in Bash before running PHPStan, it works as expected:
|
Beta Was this translation helpful? Give feedback.
Also have you seen this approach? Every team member can have their own environment-specific file, and in that file they can include the versioned file with common settings: https://phpstan.org/config-reference#multiple-files