The best way to create global variables in CakePHP


I'd like to create a global variable in CakePHP. If I define something in in my app_controller.php like

var $varName

I can access


from any of my controllers, but I cannot get to it from models.

How can I create a global variable accessible from the models?

The value of $varName isn't known until runtime, so I don't think bootstrap.php is an option.

Best Answer

CakePHP’s new Configure class can be used to store and retrieve application or runtime specific values. Be careful, this class allows you to store anything in it, then use it in any other part of your code

Related Topic