Home » Php » php – Get application environment constant in Zend Framework

php – Get application environment constant in Zend Framework

Posted by: admin July 12, 2020 Leave a comment

Questions:

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.

How to&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.

Answer:

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.