开发者

Zend framework: How to detect environment(dev/prod) in code

开发者 https://www.devze.com 2022-12-21 10:46 出处:网络
I use Zend_Mail component in my application for sending mails via SMTP protocol. And I want to persist my messages to files when I\'m in development environment(accordingly to application.ini).

I use Zend_Mail component in my application for sending mails via SMTP protocol.

And I want to persist my messages to files when I'm in development environment(accordingly to application.ini).

How can I detect in my controller acti开发者_如何学JAVAon whether it is development or production/staging environment?


If you're using Zend_Application and the ini settings load correctly (meaning the enviroment variable is setup correctly in your .htaccess file), then just use the APPLICATION_ENV constant.

That will match whatever application.ini setting is used (because that's what determines the section).


Or if managing different .htaccess files is too much hassle (or if you are not using Zend_Application), I sometimes parse the $_SERVER['HTTP_HOST'] to get the domain name then work out your environment from there.

0

精彩评论

暂无评论...
验证码 换一张
取 消