Daren W
Daren W

Reputation: 21

cakephp 3 configure class

Working with the latest version of cakephp 3. I have a plugin I am trying to install. In the plugin folder I see it's using it's own bootstrap.php executing the following code.

Configure::config('default', new PhpConfig(dirname(APP) . DS . 'config' . DS));
Configure::load('recaptcha', 'default', false);

I created the file correctly - app/config/recaptcha.php

return [
'Recaptcha' => [
    // Register API keys at https://www.google.com/recaptcha/admin
    'sitekey' => 'your-sitekey',
    'secret' => 'your-secret',
    // reCAPTCHA supported 40+ languages listed
    // here: https://developers.google.com/recaptcha/docs/language
    'lang' => 'en',
    // either light or dark
    'theme' => 'light',
    // either image or audio
    'type' => 'image',
]
];

When I try to use

Configure::read('Recaptcha'));

I get a null result. My assumption is the way they are loading the config file is wrong, could anyone please advise?

Upvotes: 1

Views: 192

Answers (1)

ADmad
ADmad

Reputation: 8100

Configure::config('default', new PhpConfig(dirname(APP) . DS . 'config' . DS));

Plugins should not be setting default config reader. It should be done in app's bootstrap. I suggest the plugin author to remove that line.

I created the file correctly - app/config/recaptcha.php

There's no "app" folder in standard Cake 3 folder structure.

Upvotes: 1

Related Questions