Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Parameterizer Bundle Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation:

    composer require elao/parameterizer-bundle
    

    Add to config/bundles.php (Symfony 4+):

    Elao\ParameterizerBundle\ElaoParameterizerBundle::class => ['all' => true],
    
  2. 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.

  3. 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
    

Implementation Patterns

Workflows

  1. Parameter Definition:

    • Use annotations (@Parameterizer\Parameterizable) or YAML/XML configs to mark properties.
    • Group parameters by context (e.g., locale, theme) via groups in annotations:
      /**
       * @Parameterizer\Parameterizable(groups={"promo"})
       */
      private $discount;
      
  2. Runtime Parameterization:

    • Inject the 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');
          }
      }
      
  3. Caching:

    • Enable caching in config (cache: true) to avoid repeated DB lookups.
    • Clear cache manually:
      php bin/console cache:clear
      
  4. Twig Integration:

    • Use the parameterize filter in templates:
      {{ product|parameterize('name', 'fr_FR') }}
      

Integration Tips

  • Doctrine ORM: Works seamlessly with Doctrine entities. Ensure your entity mappings are up-to-date.
  • Symfony Forms: Bind parameterized fields to form types dynamically:
    $builder->add('name', TextType::class, [
        'data' => $this->parameterizer->getValue($product, 'name'),
    ]);
    
  • APIs: Return parameterized data in API responses:
    return $this->parameterizer->getAllValues($product, 'en_US');
    

Gotchas and Tips

Pitfalls

  1. Deprecated Package:

    • Last release in 2014—expect compatibility issues with modern Laravel/Symfony (e.g., PHP 8.x, Symfony 5+).
    • Test thoroughly; may require patches for:
      • Doctrine ORM 2.10+.
      • Symfony DependencyInjection changes.
  2. Annotation Processing:

    • Annotations must be parsed before runtime. If using Symfony’s autoloader, ensure:
      composer dump-autoload
      
      is run after adding new annotated classes.
  3. Caching Quirks:

    • Cache keys are not namespaced by default. Override cache_key_generator in config to avoid collisions:
      elao_parameterizer:
          cache_key_generator: 'app.custom_key_generator'
      
  4. Database Schema:

    • The bundle assumes a parameter_value table exists. If migrating from an older version, run:
      php bin/console doctrine:schema:update --force
      

Debugging

  • Parameter Not Found:

    • Verify the property is annotated with @Parameterizer\Parameterizable.
    • Check the parameter_value table for existing entries:
      SELECT * FROM parameter_value WHERE entity_class = 'App\Entity\Product' AND property = 'name';
      
  • Annotation Parser Errors:

    • Enable debug mode and check logs for Doctrine\Common\Annotations\AnnotationException.
    • Manually validate annotations with:
      php bin/console debug:container Elao\ParameterizerBundle\Annotation\Parameterizable
      

Extension Points

  1. 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']
    
  2. 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()));
        }
    });
    
  3. Custom Storage: Replace the default Doctrine storage with a custom adapter by implementing ParameterStorageInterface and configuring:

    elao_parameterizer:
        storage: 'app.custom_storage'
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
elmogy/larafast
xeviant/laravel-paystack
gorilladash/laravel-website-sdk
martialbe/flysystem-oss
chondal/3312client
jeroen-g/flickr
opscale-co/nova-genbi
itsjustvita/laravel-retention
tequilarapido/trackit
gregsphotography/site-builder-filament
cabaoctavio/laravel-query-log
gregsphotography/site-builder-components
io-digital/clickatell
snowsoft/laravel-admin
oxygen/auth
relicsoftware/barakah-payment-gateway
tobya/work-with-composer
equipc/laravel-email-validator
equipc/laravel-email-database-log
adedsec/nova-translated-labels