2

I am creating PHP web application. I need to get environment variable in my web application. I am using Yosemite OSX.

I have executed following command:

launchctl setenv ENVIRONMENT development

I am able to get o/p for the following command:

launchctl getenv ENVIRONMENT 
development

However, when I execute following in my PHP file

$env = getenv('ENVIRONMENT');
echo $env;

I am not able to see the result "development".

For setting environment variable I have also tried following: http://www.jochenhebbrecht.be/site/2015-04-14/mac/os-x-1010-yosemite-and-environment-variables

Setting environment variables via launchd.conf no longer works in OS X Yosemite/El Capitan/macOS Sierra?

I have also executed following command:

launchctl load ~/Library/LaunchAgents/my.startup.plist
launchctl start ~/Library/LaunchAgents/my.startup.plist

When I execute launchctl load ~/Library/LaunchAgents/my.startup.plist it gives me

Library/LaunchAgents/my.startup.plist: Operation already in progress

Also restart MAMP server, restart macbook. Did this for few times. But no success.

Can anyone please tell me what am I doing wrong?

If someone can tell me necessary steps to achieve final goal which is to use environment variable in my PHP application, I would be really grateful.

Thanks in advance.

Community
  • 1
  • 1
Sahil
  • 491
  • 2
  • 9
  • 18
  • this type of question is best addressed at http://superuser.com – YvesLeBorg Aug 16 '15 at 12:35
  • thanks @YvesLeBorg for your suggestion. also posted on superuser.com – Sahil Aug 16 '15 at 12:39
  • possible duplicate of [Setting environment variables via launchd.conf no longer works in OS X Yosemite?](http://stackoverflow.com/questions/25385934/setting-environment-variables-via-launchd-conf-no-longer-works-in-os-x-yosemite) – nomistic Aug 16 '15 at 13:04

0 Answers0