在CakePHP中访问Configuration :: read in Controller [英] Accessing Configuration::read in Controller in CakePHP

查看:65
本文介绍了在CakePHP中访问Configuration :: read in Controller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的CakePHP应用程序有一个单独的配置文件,该文件已加载到bootstrap.php中。我的问题是,如何在控制器中访问配置的变量?即如何在Controller中执行Configure :: read('variable')函数?谢谢!

I have a separate config file for my CakePHP application which is loaded in the bootstrap.php. My question is, how can I access the Configuration's variables in my Controller? I.e. How can I perform the Configure::read('variable') function in Controller? Thanks!

推荐答案

请阅读文档。
在那里很好地解释了如何加载自定义配置文件:
http://book.cakephp.org/2.0/en/development/configuration.html#loading-configuration-files

默认情况下,如类本身所记录的那样,它将合并其配置与已加载的配置。

By default, as documented in the class itself, it will merge its configs with the already loaded configs.

Configure::read('variable')

然后如果覆盖新的应用程序,则加载新配置的内容。

then loads the content of the new config if it overwrites the app one.

这篇关于在CakePHP中访问Configuration :: read in Controller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆