Download the PHP package gupalo/config-bundle without Composer
On this page you can find all versions of the php package gupalo/config-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download gupalo/config-bundle
More information about gupalo/config-bundle
Files in gupalo/config-bundle
Package config-bundle
Short Description Editable config rows backed by an EasyAdmin CRUD
License MIT
Informations about the package config-bundle
Config Bundle
A two-column config table (name unique, value text) wired to an EasyAdmin CRUD.
Drop the bundle in, register MenuItem::linkTo(ConfigCrudController::class, 'Config', …),
and your IMAGE_* / FEATURE_* flags become admin-editable without a redeploy.
Requirements
- PHP 8.4+
- Symfony 7.4 or 8.0+
- Doctrine ORM 3.x
- EasyAdmin 5
Install
Composer
composer req gupalo/config-bundle
The bundle is auto-registered; no bundles.php edit needed.
Create the config table:
php bin/console make:migration
php bin/console doctrine:migrations:migrate -n
Declare possible values and their defaults in config/services.yaml. The type of each
default decides how ConfigRepository::getValue() decodes the stored string — a fresh
row is seeded with the default on first read, so a brand-new deploy that visits the CRUD
sees the same numbers the env vars would have produced.
parameters:
...
config.defaults:
SOME_INT: 0
SOME_BOOL: true
SOME_DATETIME: '-2 days'
Wire the menu entry in your EasyAdminMenu::configureMenuItems():
use Gupalo\ConfigBundle\Controller\ConfigCrudController;
yield MenuItem::linkTo(ConfigCrudController::class, 'Config', 'fas fa-gears');
EasyAdmin picks up the controller automatically — no routing file to add.
Reading values from your services
ConfigRepository is autowired and public. Use the typed accessors (the type comes from
the default you declared above, so an int default gives you getIntValue(), a bool
default gives you getBoolValue(), etc.):
public function __construct(
private readonly ConfigRepository $configRepository,
#[Autowire('%env(int:IMAGE_REFILL_PER_HOUR)%')]
private readonly int $perHourFallback = 20,
) {}
public function perHour(): int
{
// Config-bundle row wins; env var is the fallback for the row-not-present case.
return max(1, $this->configRepository->getIntValue('IMAGE_REFILL_PER_HOUR', $this->perHourFallback));
}
getStringValueCached() is the cached variant (60s TTL via FilesystemAdapter) — use it
from the daemon's tick loop; the un-cached accessors hit the DB on every call.
Upgrading from 1.x
1.x shipped a custom form-based UI at /config. 2.0 removes it — the only UI is the
EasyAdmin CRUD.
- Delete
config/routes/config.yamlif you added it for 1.x; the bundle no longer ships routing. - In
EasyAdminMenu, replace anyMenuItem::linkToUrl('Config', …, '/config')withMenuItem::linkTo(Gupalo\ConfigBundle\Controller\ConfigCrudController::class, 'Config', …). - The
Configentity andConfigRepositoryAPI (getValue,getIntValue,getBoolValue,getStringValueCached, …) are unchanged.
All versions of config-bundle with dependencies
doctrine/doctrine-bundle Version ^3.0
doctrine/orm Version ^3.0
easycorp/easyadmin-bundle Version ^5.0
gupalo/dateutils Version ^1.20
symfony/cache Version ^7.4|^8.0
symfony/framework-bundle Version ^7.4|^8.0
symfony/yaml Version ^7.4|^8.0
twig/twig Version ^3.22