24-11-2009

Zend Framework Set constants in ZF application ini file

To be able to set application wide constants inside the application ini file you can define a function as follows in the bootstrap class:

protected function setconstants($constants){
        foreach ($constants as $key=>$value){
            if(!defined($key)){
                define($key, $value);
            }
        }
}
 

Now in you application.ini you can define contants like so:

constants.PREVIEW_PATH = /cache/previews/

Comments:

6 comments.
Your comment:

»
DK 30/03/2010, 1:53 am
Thanks!
Juris 22/09/2010, 1:55 pm
Thank you...
Matt 19/10/2010, 2:17 pm
Perfect, thank you
Sergey 27/12/2010, 1:21 pm
Everyday get to know something new. Thank you.
Ben 02/08/2011, 11:48 pm
me too :)
DevBrPb 01/09/2011, 3:24 am
Great, another way to do it is used in the .htaccess but i application.ini is more correct in my opinion.

thanks!!

 

[x]