elao/parameterizer-bundle
Symfony bundle integrating ElaoParameterizer to manage PHP parameters via a dat.GUI-based UI. Define parameter “patterns” programmatically, in YAML config, or as tagged services to tweak values and options (labels, choices) during development.
Installation:
composer require elao/parameterizer-bundle
Add to config/bundles.php (Symfony 4+):
Elao\ParameterizerBundle\ElaoParameterizerBundle::class => ['all' => true],
Configuration:
Locate the default config at vendor/elao/parameterizer-bundle/Resources/config/config.yml and publish it:
php bin/console elao:parameterizer:install
Override defaults in config/packages/elao_parameterizer.yaml.
First Use Case:
Define a parameterizable entity (e.g., Product):
// src/Entity/Product.php
use Elao\ParameterizerBundle\Annotation as Parameterizer;
class Product {
/**
* @Parameterizer\Parameterizable
*/
private $name;
/**
* @Parameterizer\Parameterizable(type="text")
*/
private $description;
}
Generate parameter definitions:
php bin/console elao:parameterizer:generate
Parameter Definition:
@Parameterizer\Parameterizable) or YAML/XML configs to mark properties.locale, theme) via groups in annotations:
/**
* @Parameterizer\Parameterizable(groups={"promo"})
*/
private $discount;
Runtime Parameterization:
Parameterizer service to resolve values:
use Elao\ParameterizerBundle\Parameterizer\ParameterizerInterface;
class ProductService {
public function __construct(private ParameterizerInterface $parameterizer) {}
public function getLocalizedName(Product $product) {
return $this->parameterizer->getValue($product, 'name', 'en_US');
}
}
Caching:
cache: true) to avoid repeated DB lookups.php bin/console cache:clear
Twig Integration:
parameterize filter in templates:
{{ product|parameterize('name', 'fr_FR') }}
$builder->add('name', TextType::class, [
'data' => $this->parameterizer->getValue($product, 'name'),
]);
return $this->parameterizer->getAllValues($product, 'en_US');
Deprecated Package:
Annotation Processing:
composer dump-autoload
is run after adding new annotated classes.Caching Quirks:
cache_key_generator in config to avoid collisions:
elao_parameterizer:
cache_key_generator: 'app.custom_key_generator'
Database Schema:
parameter_value table exists. If migrating from an older version, run:
php bin/console doctrine:schema:update --force
Parameter Not Found:
@Parameterizer\Parameterizable.parameter_value table for existing entries:
SELECT * FROM parameter_value WHERE entity_class = 'App\Entity\Product' AND property = 'name';
Annotation Parser Errors:
Doctrine\Common\Annotations\AnnotationException.php bin/console debug:container Elao\ParameterizerBundle\Annotation\Parameterizable
Custom Parameter Sources:
Override the ParameterSource interface to fetch values from non-DB sources (e.g., API):
class ApiParameterSource implements ParameterSourceInterface {
public function getValue($entity, $property, $context) {
return $this->apiClient->fetch($entity->getId(), $property);
}
}
Register it in services.yaml:
services:
app.api_parameter_source:
class: App\Service\ApiParameterSource
tags: ['elao_parameterizer.parameter_source']
Event Listeners:
Extend parameter behavior via events (e.g., ParameterizerEvents::PRE_GET_VALUE):
use Elao\ParameterizerBundle\Event\ParameterizerEvents;
$dispatcher->addListener(ParameterizerEvents::PRE_GET_VALUE, function ($event) {
if ($event->getProperty() === 'name') {
$event->setValue(strtoupper($event->getValue()));
}
});
Custom Storage:
Replace the default Doctrine storage with a custom adapter by implementing ParameterStorageInterface and configuring:
elao_parameterizer:
storage: 'app.custom_storage'
How can I help you explore Laravel packages today?