Can't get env vars in PHP

I set env variables in circle.yml and project settings too but i can’t fetch them in PHP app using _SERVER or _ENV.
Anything that am missing? Thanks.

Please show related bits of your circle.yml file.

Thanks alexander.
Below is my circle.yml

    version: 5.6.17
    ENVIRONMENT: development 
    CIRCLE_ENV: test
    DATABASE1_NAME: xxxx
    DATABASE1_USER: xxxx
    DATABASE1_PASS: xxxx
    NGROK_TOKEN: xxxx
    GHOST_API_KEY: xxxx
    GHOST_SUITE_ID: xxxx

and i fetch them with:


both are undefined.

Hi @alexander. can you please help. Thanks.

The configuration looks fine. Hmm… maybe try using getenv function instead of reading SERVER and ENV?

@alexander nothing working , i tried getenv function, tried $GLOBALS
This is very strange, i can use these env variables in circle.yml but can’t get them in php.

How is PHP being run and by what user? Environment variables for CircleCI will be defined in /home/ubuntu/.circlerc. This file needs to be sourced by the same user running PHP for those variables to be available.

So for example, if you were running PHP via Apache, which uses the www-data user by default, they wouldn’t be available.

@FelicianoTech I do have two more env variables in circle.yml


so apache and php both running under ubuntu user.

And what should we do so PHP via Apache can see the Environment Variables?