This bundle provides a simple way to manage settings in your Symfony application as a key-value. Sensitive data is encrypted. If you want to update the sensitive setting, you need to send the raw value again. The bundle provides an API to manage settings.
composer updategenerated as follows:
echo sodium_bin2hex(sodium_crypto_secretbox_keygen());Add the generated key to your .env file:
CRYPTO_KEY=your_generated_key
Ensure that you have the variable in docker compose file:
environment:
- CRYPTO_KEY=${CRYPTO_KEY}
Then, enable the bundle by adding it to the list of registered bundles:
// config/bundles.php
return [
// ...
Hengebytes\SettingBundle\HBSettingBundle::class => ['all' => true],
];
}Then, enable the routes by adding it to the route list
in the app/config/routing.yml file of your project:
# app/config/routing.yml
setting_routes:
resource: "@HBSettingBundle/Resources/config/routing.yml"
prefix: / # some admin path prefixIf you want to use admin UI you need to install assets:
$ php bin/console assets:installInclude the following in your config/routes.yaml file:
setting_api:
resource: "@HBSettingBundle/Resources/config/api_routing.yml"
prefix: /apiThe API is not secured by default. You should secure it by adding a firewall in your config/packages/security.yaml file:
security:
firewalls:
setting_api:
pattern: ^/api/settings
stateless: true
anonymous: false
provider: app_user_provider
guard:
authenticators:
- lexik_jwt_authentication.jwt_token_authenticatorList of settings can be retrieved by the following request:
GET /api/settings/list
POST /api/settings
POST requests should have the following body
{
"name": "general/stuff/secret1",
"value": "test",
"is_sensitive": false
}DELETE /api/settings/list
DELETE requests should have the following body:
{
"settings": ["setting/line1", "setting/line2", "setting/line3"]
}POST /api/settings/list
POST requests should have the following body:
{
"settings": [
{
"name": "setting/line1",
"value": "test",
"is_sensitive": false
},
{
"name": "setting/line2",
"value": "test",
"is_sensitive": false
},
{
"name": "setting/line3",
"value": "test",
"is_sensitive": false
}
]
}