Cakephp 自定义配置文件错误

Cakephp 自定义配置文件错误,cakephp,Cakephp,我想为站点配置创建一个配置文件。我创建config.php并将其放入config文件夹。它的内容是: <?php Configure::write('Title', 'My App'); Configure::write('Categories', array( 'Recipes' => array('url' => '/recipe', 'max' => 10), 'Foods' => array('url' =

我想为站点配置创建一个配置文件。我创建
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)
));
但cake返回以下错误:

有什么问题吗


注意:我使用的是最新版本:2.2.1 Stable

在配置文件中,如果要将
load()
与默认phpreder一起使用,则应使用名为
$config
的数组变量,而不是Configure::write。看


谢谢,如果我想使用
Configure::write
需要哪个函数?我应该把
Configure::config('config')
放进去吗?一般来说,在cake中创建应用程序配置文件的最佳标准方法是什么?这就是
bootstrap.php
的用途。如果您想将它放在一个单独的文件中,那么在
bootstrap.php
中使用
include config.php
可能是最简单的。我不确定另一种方法。确切地说,对于CakePHP 3.4及以上版本,使用数组加载()并使用Configure::write()包含/需要此链接=>
Configure::load('config');
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)
<?php
$config = array(
    'Title' => 'MyApp',
    ...
);