【发布时间】:2012-07-18 15:49:25
【问题描述】:
我想为站点配置创建一个配置文件。我创建config.php 并将其放入Config 文件夹中。这是它的内容:
<?php
Configure::write('Title', 'My App');
Configure::write('Categories', array(
'Recipes' =>
array('url' => '/recipe', 'max' => 10),
'Foods' =>
array('url' => '/food', 'max' => 5)
));
并将这段代码放在bootstrap.php的末尾:
Configure::load('config');
但是 cake 返回这个错误:
No variable $config found in ...........\app\Config\config.php.php Error: An Internal Error Has Occurred. Stack Trace CORE\Cake\Core\Configure.php line 272 → PhpReader->read(string) APP\Config\bootstrap.php line 110 → Configure::load(string) CORE\Cake\Core\Configure.php line 92 → include(string) CORE\Cake\bootstrap.php line 142 → Configure::bootstrap(boolean) APP\webroot\index.php line 79 → include(string)
有什么问题??
注意:我使用的是最新版本:2.2.1 稳定版
【问题讨论】:
-
对于 CakePHP 3.4 及更高版本 请参考此链接 => Accessing Configuration::read in Controller in CakePHP
标签: cakephp