Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.
Open a command console, enter your project directory and execute:
$ composer require kaliber5/settings-bundle
Continue with Step 3.
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require kaliber5/settings-bundle
Then, enable the bundle by adding it to the list of registered bundles
in the config/bundles.php
file of your project:
// config/bundles.php
return [
// ...
Kaliber5\SettingsBundle\Kaliber5SettingsBundle::class => ['all' => true],
];
Then, adjust your database structure to add the new entities.
$ bin/console doctrine:migrations:diff
$ bin/console doctrine:migrations:migrate
If you're already using sonata admin-bundle, the settings admin will be available immediatly to add settings
in your code you can retrieve the settings by using the SettingsProvider
:
// ...
use Kaliber5\SettingsBundle\Provider\SettingsProvider;
// ... in some class
/**
* @var SettingsProvider
*/
private $settingsProvider;
// ...in some method
$mixed = $this->settingsProvider->getSettingValuesByCode('unique_code_of_setting');