Settings plugin for CakePHP
Installation
You can install this plugin into your CakePHP application using composer., (*1)
The recommended way to install composer packages is:, (*2)
composer require jorisvaesen/cakephp-settings
Enable plugin:, (*3)
bin/cake plugin load -b JorisVaesen/Settings
Migrate settings table, (*4)
bin/cake migrations migrate -p JorisVaesen/Settings
Usage
Create setting, (*5)
bin/cake joris_vaesen/settings.create
Read setting, (*6)
use JorisVaesen\Settings\Settings;
echo Settings::read($name);
Write setting, (*7)
// Using simple find and update
$settingsTable = TableRegistry::getTableLocator()->get('JorisVaesen/Settings.Settings');
$setting = $settingsTable->find('name', ['name' => 'SETTING_NAME'])->first();
$setting->set('value', 'NEW VALUE');
$settingsTable->save($setting);
// Write method
TableRegistry::getTableLocator()->get('JorisVaesen/Settings.Settings')
->write('NAME', 'NEW_VALUE');