1

I currently have a script which will run via the browser and separately via the "php" command line tool.

Now the problem is, I am able to access the Apache Environment variables while script being called from the browser, but unable to access it while the script is called via command line.

How can I get the Apache environment available to the command line script as well ?

2
  • 1
    I hope you realise that the reason you get the environment variables when accessing the page from a browser is because the script is being run frome inside the Apache process, and when you run from the command line it is not. What OS is this on? Commented Jul 16, 2012 at 11:20
  • 1
    I would suggest that you pass the needed Apache Environment Variables to the CLI script using command line arguments. Commented Jul 16, 2012 at 11:48

1 Answer 1

5

First, you must declare your environment variable using this command:

export APPLICATION_ENV=development

Then you can get it in your application cli with the function getenv('APPLICATION_ENV');.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.