配置Behat将env变量设置为test

I've created a simple php application from scratch. In my composer.json I've this dependencies. They all works fine, but I also need to create a "test" environment (with different configurations).

In symfony this is done automatically. I suppose I need to export some variable in bash. Some env variable.

{
    "require-dev": {
        "phpunit/phpunit": "^5.5",
        "behat/behat": "^3.2",
        "behat/mink-extension": "@dev",
        "behat/mink-goutte-driver": "@dev"
    }
}

I've tryed with bash script like this:

# bash
export MY_VAR=test

but when I try to read the variable with

// php
var_dump(getenv('MY_VAR'))

var_dump always returns false.

Not sure why you mentioned composer - it has nothing to do with environment configuration.

getenv works perfectly fine for php_cli:

$ MY_VAR=test php -r "var_dump(getenv('MY_VAR'));"

outputs string(4) "test".

For mod_php you should set environment variable in relevant VirtualHost definition:

SetEnv MY_VAR test

and for php_fpm you should do the same in relevant pool.d/ config:

env[MY_VAR] = test