I want to a create a config file for site configuration. I create config.php and put it into the Config folder. It’s its content:
<?php
Configure::write('Title', 'My App');
Configure::write('Categories', array(
'Recipes' =>
array('url' => '/recipe', 'max' => 10),
'Foods' =>
array('url' => '/food', 'max' => 5)
));
And put this code at the end of bootstrap.php:
Configure::load('config');
But cake returns this error:
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)
What’s the problem??
Note: I’m using the latest version: 2.2.1 Stable
In your config file you should be using an array variable called
$configinstead of Configure::write if you want to useload()with the default PhpReader. See APIEx.
http://book.cakephp.org/2.0/en/development/configuration.html#built-in-configuration-readers