How to set environment variable in MAMP?

ⅰ亾dé卋堺 提交于 2019-12-04 16:19:49

found the solution. In /Applications/MAMP/conf/apache/httpd.conf added following:

SetEnv MY_TEST_DETAIL foo

At least for MAMP PRO (version 3.5) from the menu you could find and edit your apache httpd.conf file.

File -> Edit Template -> Apache -> httpd.conf

...you could add something like this:

SetEnv ENVIRONMENT development

And then in PHP you can get the environmental variable like so:

$env = getenv('ENVIRONMENT');

if($env == "development") {
   $db_host = "localhost";
}

Just be mindful that if/when you update or upgrade MAMP it'll likely overwrite this httpd.conf file with a newer verion.

# This file is generated from envvars-std.in

I am not sure but maybe you haven't changed the good file.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!