Best way to load plugin configurations?

Corecast is a GUI for the Icecast 2 streaming server. I built it using CakePHP 3, and then converted it into plugin form. Loading the custom configuration file was simple in the original app, as it was stored in the same directory with app.php and of course I added a line to bootstrap.php to load it.

I can’t seem to figure out how to load the custom configuration in the plugin form, but I am sure that I prefer not to ask the user to move the configuration for the plugin outside of the plugin folder, nor do I want to have to leave any mark of code outside of the plugin folder apart from loading the plugin itself.

In my main application’s config/bootstrap.php, I added the following line:

Plugin::load('Corecast', ['bootstrap' => true, 'routes' => true]);

In my plugin’s config folder, I created a bootstrap.php file, and in it:

use Cake\Core\Configure;

try {
    Configure::load('Corecast.corecast', 'default', false);
} catch (\Exception $e) {
    exit($e->getMessage() . "\n");

The above call to Configure::load() is given the plugin name and the name of the configuration file, in plugin notation. My custom configuration file is named corecast.php and it is also in my plugin’s config folder.


use Cake\Core\Configure;
use Cake\Routing\Router;

$config = [
    'Users' => [
        //Table used to manage users
        'table' => 'CakeDC/Users.Users',
        //configure Auth component
        'auth' => true,

Read users tabel value from configuration


You can see example from CakeDC Users plugin

Here is documentaion