Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get application environment constant in Zend Framework

i am new to Zend Framework and i want to know how to get the application environment in my controller.

I read in a forum to use: echo getenv('APPLICATION_ENV'); but it does not work.

like image 257
shasi kanth Avatar asked Mar 02 '11 16:03

shasi kanth


2 Answers

Since APPLICATION_ENV is a constant, you can access it simply with:

echo APPLICATION_ENV;

But the question is why would you need it in your controller.

like image 110
Vika Avatar answered Oct 15 '22 21:10

Vika


There is another way to get the environment name. It's a little more OO-friendly for those of us who prefer to avoid globally defined constants, but I'm not quite sure how to get at it:

$myEnvName = $zendApplicationInstance->getEnvironment();

The question here is how to get the reference to $myEnvName -- suggestions welcome.

like image 24
Memethief Avatar answered Oct 15 '22 21:10

Memethief