Weave Code
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

Contao Config Driver Bundle Laravel Package

oveleon/contao-config-driver-bundle

Adds a Config data container driver to Contao CMS. Load DCA palettes/fields from template or bundle config files and render them in the backend. Store values in localconfig or serialize them into an existing DB column, with support for overrides and merging.

View on GitHub
Deep Wiki
Context7
## Getting Started
Install the package via Composer:
```bash
composer require oveleon/contao-config-driver-bundle:^1.5.0

First Use Case: Leverage Laravel's container to dynamically load Contao DCA field options. Define a field with container-aware options:

// config/contao/dca/tl_content.php
$GLOBALS['TL_DCA']['tl_content']['fields']['dynamic_field'] = [
    'inputType' => 'select',
    'options' => [
        'container_param' => 'app.contao.options', // Reference a container-bound service
        'fallback' => ['default' => 'value'],      // Fallback if container fails
    ],
    'eval' => ['tl_class' => 'clr'],
];

Key Steps:

  1. Bind your options provider in config/services.php:
    'app.contao.options' => function () {
        return require __DIR__.'/contao/options.php';
    },
    
  2. Clear caches to apply changes:
    php artisan cache:clear
    php artisan contao:cache:clear
    

Implementation Patterns

Dynamic Option Resolution

Use container parameters for runtime flexibility:

// config/services.php
'app.contao.options' => function ($app) {
    return $app['cache']->remember('contao_options', now()->addHours(1), function () {
        return $this->fetchOptionsFromDatabase(); // Custom logic
    });
},

Workflow Integration

  1. Define Container Bindings: Register services in config/services.php or AppServiceProvider.
  2. Reference in DCA: Use container_param with fallback values.
  3. Cache Management: Clear caches after modifying container bindings or options.

Advanced Patterns

  • Environment-Specific Options:
    'container_param' => env('APP_ENV') === 'production' ? 'app.prod_options' : 'app.dev_options',
    
  • Database-Driven Options:
    'container_param' => function () {
        return \App\Models\ContaoOption::pluck('value', 'key')->toArray();
    },
    
  • Multi-Tenant Support:
    'container_param' => 'app.contao.options.'.auth()->user()->tenant_id,
    

Gotchas and Tips

Pitfalls

  • Circular Dependencies: Avoid binding container_param to a DCA field that itself relies on container options (e.g., tl_content options loading from tl_content).
  • Cache Staleness: Always clear caches after modifying container bindings or options:
    php artisan cache:clear
    php artisan contao:cache:clear
    
  • Fallback Overrides: Fallback values are merged, not replaced. Explicitly structure fallbacks for clarity:
    'options' => [
        'container_param' => 'app.options',
        'fallback' => ['static' => ['option' => 'value']],
    ],
    

Debugging

  • Parameter Resolution Errors: Verify bindings exist:
    $this->app->bound('app.contao.options') // Check binding.
    $this->app->make('app.contao.options')->toArray(); // Inspect value.
    
  • File Path Issues: Use absolute paths or container-aware placeholders (e.g., %kernel.project_dir%/config/options.php).
  • Container Initialization: Ensure the container is fully bootstrapped before resolving parameters (e.g., avoid early static calls).

Extension Points

  • Custom Loaders: Extend \Oveleon\ContaoConfigDriverBundle\Loader\ContainerParameterLoader to support:
    • API-driven options (e.g., fetch from a remote service).
    • Conditional logic (e.g., load options based on request data).
  • Event Hooks: Listen to ContaoConfigDriverEvents::PRE_LOAD to pre-process parameters:
    Event::listen(ContaoConfigDriverEvents::PRE_LOAD, function ($event) {
        if ($event->getParameter() === 'app.contao.options') {
            $event->setParameter($this->enrichOptions($event->getParameter()));
        }
    });
    
  • Fallback Strategies: Override the default fallback behavior by implementing Oveleon\ContaoConfigDriverBundle\Contracts\FallbackStrategy.

Configuration Quirks

  • Type Safety: Container parameters are resolved as-is. Ensure return types match expected array structures.
  • Lazy Loading: For performance, bind options as lazy services (e.g., closures) to defer loading until needed.
  • Environment Variables: Use env() or config() within container bindings for dynamic values:
    'app.contao.options' => function () {
        return ['timeout' => config('contao.timeout')];
    },
    

NO_UPDATE_NEEDED would **not** apply—this release introduces **container parameter support**, which is a **breaking/major feature** requiring updated patterns, debugging tips, and workflows. The assessment now reflects **real-world Laravel integration** (e.g., caching, service binding, fallbacks) and **advanced use cases** (multi-tenancy, API-driven options).
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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky