脚本宝典收集整理的这篇文章主要介绍了开发环境 – CakePHP中的不同环境?,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
为此,您可以创建一个检查服务器名称的custom.PHP配置.
$domain = strtolower(@$_SERVER['SERVER_NamE']); swITch (true) { default: case 'production.domain.COM' == $domain: Configure::write('MyDomain.environment','production'); break; case 'staging.domain.com' == $domain: Configure::write('MyDomain.environment','staging'); break; case 'local.domain.com' == $domain: case 'myBox.com' == $domain: Configure::write('MyDomain.environment','local'); break; }
现在,在核心中,您可以根据您的环境配置设置:
switch (Configure::read('MyDomain.environment')) { default: // for security; wouldn't want any confusion revealing sensitive information case 'production': Configure::write('debug',0); break; case 'staging': case 'local': Configure::write('debug',2); break; }
现在,您可以使用Configure :: write(‘MyDomain.environment’,x)在任何地方配置所有内容,而无需修改CakePHP核心读取文件的方式.
快乐的编码!
以上是脚本宝典为你收集整理的开发环境 – CakePHP中的不同环境?全部内容,希望文章能够帮你解决开发环境 – CakePHP中的不同环境?所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。