fuel-lbConfig-package is a package for easily managing config file in FuelPHP.
- Clone or download the fuel-lbConfig-package repository
- Move it into your packages folder, and rename it to "lbConfig"
- Add 'lbConfig' to the 'always_load.packages' array in app/config/config.php at first position (important!).
- Open fuel/app/bootstrap.php and replace these lines :
// Initialize the framework with the config file.
Fuel::init('config.php');
by
\Config::load('config.php');
\Package::load('lbConfig');
// Initialize the framework with the config file.
Fuel::init('config');
- You will add all config key you want to manage in your backoffice, in the lbConfig config file.
- In first, FuelPHP will load the config.php
- And load the package lbConfig, which will read the lbConfig config file, and override all config keys before Fuel::init()
Copy/paste the lbconfig.php file in your app/config folder, and edit it :
All config keys need to be in the key "configs"
'configs' =>
array(
'config' =>
array(
'file' => 'config', // The name of the config file (here config.php)
'module' =>
array(
'tab' => 'App', // The name of the tab in bootstrap 3 (for config module)
'panel' => 'Config', // The name of the panel in bootstrap 3
),
// All config keys here :
'list' =>
array(
// The key is 'profiling', for activate or not Fuel Profiler
'profiling' =>
array(
'value' => true,
),
),
),
),
'profiling' =>
array(
'label' => 'Use profiler ?',
'value' => true,
),
'profiling' =>
array(
'label' => 'Use profiler ?',
'panel' => 'Profiler', // I don't want to use the panel "Config"
'value' => true,
),
'language' =>
array(
'label' => 'Language',
'value' => 'fr',
'values' =>
array(
0 => 'en',
1 => 'fr',
'Japonais' => 'jp',
),
),
For example you want to manage the key "cookie.expiration" in config.php :
'cookie.expiration' =>
array(
'label' => 'Cookie expiration',
'value' => 0,
),
Will not work ! You can use "." as separator. The default separator is ">" :
'cookie>expiration' =>
array(
'label' => 'Cookie expiration',
'value' => 0,
),
Will work ! You can customize the separator in the config key : lbconfig.separator
You can use rules validations like that :
'cookie>expiration' =>
array(
'label' => 'Cookie expiration',
'value' => 0,
'rules' => array(
array('required'),
array('valid_string', array('numeric')),
array('numeric_min', 0),
),
),
it's only for the lbConfig module
Want to use the key in other file config ?
'configs' =>
array(
// The config file
'config' =>
array(
'file' => 'config', // The name of the config file (here config.php)
'module' =>
array(
'tab' => 'App', // The name of the tab in bootstrap 3 (for config module)
'panel' => 'Config', // The name of the panel in bootstrap 3
),
// All config keys here :
'list' =>
array(
// The key is 'profiling', for activate or not Fuel Profiler
'profiling' =>
array(
'value' => true,
),
),
),
// Image config file
'image' =>
array(
'file' => 'image', // The name of the config file (here image.php)
'module' =>
array(
'tab' => 'Image', // The name of the tab in bootstrap 3 (for config module)
'panel' => 'Config', // The name of the panel in bootstrap 3
),
// All config keys here :
'list' =>
array(
// The key is 'quality' (image.quality), for choose the active theme
'quality' =>
array(
'value' => 100,
),
),
),
),
For manage easily this package, you need to install the lbConfig module here