I have 50 controllers, and 90 Models. Everywhere i was using/repeating same words ‘login’ and ‘success’. I want to make one global constant so that i can access from anywhere in my controllers and models. How or where do you declare this following 2 line.
Try to put this somewhere to have global access:
defined('MYFIXED_WORD_SUCCESS')
|| define('MYFIXED_WORD_SUCCESS', "success");
defined('MYFIXED_WORD_LOGIN')
|| define('MYFIXED_WORD_SUCCESS', "login");
Example of repeating:
if (count($result) > 0)
{
$return = array(
'flag' => 'login', // replace it with MYFIXED_WORD_
'result'=> 'success',// replace it with MYFIXED_WORD_
'extra' => array(group'=>$rec->group,));
Anything you include or set in bootstrap.php should be available from anywhere in your application. But have a look at Zend_Translate since it does pretty much what you want but in a organised way.
Alternatively you could set it in application.ini and get to it thru Zend_Config.
You “could” put it in /public/index.php but in my opinion its not the place to put such thing. Imagine when you have thousands of const like that how it would polute a file that basically never should change.