c975l / config-bundle
Used to get/set the config params for a Symfony app
Requires
- php: >=8.0
- doctrine/orm: *
- easycorp/easyadmin-bundle: *
- sensiolabs/minify-bundle: *
- symfony/form: *
- symfony/yaml: *
Requires (Dev)
This package is auto-updated.
Last update: 2026-06-27 18:51:23 UTC
README
A Symfony bundle that stores application configuration as key-value pairs in the database, with an EasyAdmin management interface, Twig/PHP accessors, and production deployment tooling.
Features
- Key-value config entries stored in the database (
site_configtable) - EasyAdmin CRUD interface to manage values
- SQL export button for production deployment
- Twig and PHP service to read values anywhere
- 1-hour cache with automatic invalidation on change
Installation
composer require c975l/config-bundle
Run the database migration to create the site_config table:
php bin/console doctrine:migrations:diff php bin/console doctrine:migrations:migrate
Defining config entries for your bundle
Create a config/configs.json file in your bundle. Each entry will be inserted into the database on first load (duplicates are skipped):
[
{
"label": "Site Name",
"slug": "site-name",
"sensitive": false,
"value": null,
"kind": "text",
"description": "Name of the website"
},
{
"label": "Maintenance Mode",
"slug": "site-maintenance",
"sensitive": true,
"value": "false",
"kind": "bool",
"description": "Set to true to enable maintenance mode"
},
{
"label": "Stripe Secret Key",
"slug": "stripe-secret-key",
"sensitive": true,
"value": null,
"kind": "text",
"description": "Stripe secret key (sk_live_...)"
}
]
Supported kind values: text, int, bool.
Set sensitive: true for any entry that holds secrets (API keys, passwords, etc.).
Loading config entries into the database
Auto-discovers every vendor/c975l/*/config/configs.json file and loads them in one shot:
php bin/console c975l:config:load-all
EasyAdmin interface
The bundle registers a management dashboard at /management. Navigate to Config to view, create, edit, or delete entries.
Deploying to production — Export SQL
On the config list page, click the Export SQL button. The browser downloads a site_config_YYYYMMDD_HHMMSS.sql file — nothing is written to disk or version control.
Import it on your production server:
mysql -u user -p dbname < site_config_20260626_120000.sql
Behavior per entry type:
is_sensitive |
SQL statement | Effect on production |
|---|---|---|
false |
INSERT … ON DUPLICATE KEY UPDATE |
Creates or updates label, value, kind, description |
true |
INSERT IGNORE INTO |
Creates if missing; preserves existing production value |
This means non-sensitive values (labels, descriptions, default content) are kept in sync, while live API keys and secrets already set on production are never overwritten.
Reading config values
In PHP
use c975L\ConfigBundle\Service\ConfigServiceInterface; class MyService { public function __construct( private readonly ConfigServiceInterface $configService, ) {} public function doSomething(): void { $siteName = $this->configService->get('site-name'); // string $maxItems = $this->configService->get('max-items'); // int (auto-cast) $isEnabled = $this->configService->get('feature-enabled'); // bool (auto-cast) $env = $this->configService->getContainerParameter('kernel.environment'); } }
In Twig
{# Read from database #} {{ config('site-name') }} {# Read from Symfony container parameters #} {{ configParam('kernel.environment') }}
License
MIT — see LICENSE.