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

Domainator9K Apptype Generic Bundle Laravel Package

digipolisgent/domainator9k-apptype-generic-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the bundle via Composer:

    composer require district09/domainator9k-apptype-generic-bundle
    

    Enable it in config/bundles.php (Symfony) or config/app.php (Laravel via Symfony bridge):

    return [
        // ...
        District09\Domainator9kApptypeGenericBundle\District09Domainator9kApptypeGenericBundle::class => ['all' => true],
    ];
    
  2. First Use Case: Defining a Generic App Type Create a custom command or service to register a new app type:

    use District09\Domainator9kApptypeGenericBundle\Domainator9kApptypeGenericBundle;
    use District09\Domainator9kApptypeGenericBundle\Domainator9kApptypeGenericEvents;
    
    // In a service or command:
    $bundle = new Domainator9kApptypeGenericBundle();
    $bundle->registerAppType('my_custom_app', [
        'name' => 'My Custom App',
        'description' => 'A generic app type for custom use cases',
        'icon' => 'fa-cog',
        'configurable_fields' => [
            'field1' => ['type' => 'text', 'label' => 'Field 1'],
            'field2' => ['type' => 'select', 'label' => 'Field 2', 'options' => ['opt1', 'opt2']],
        ],
    ]);
    
  3. Triggering Events Listen for app type events (e.g., creation, update) via Symfony's event dispatcher:

    // In a service provider or event subscriber:
    $dispatcher->addListener(Domainator9kApptypeGenericEvents::APP_TYPE_CREATED, function ($event) {
        // Handle app type creation logic
    });
    

Implementation Patterns

Workflow: App Type Management

  1. Registration Use the bundle’s Domainator9kApptypeGenericBundle to dynamically register app types at runtime (e.g., via a CLI command or admin panel).

    $bundle->registerAppType('blog', [
        'configurable_fields' => [
            'title' => ['type' => 'text', 'required' => true],
            'theme' => ['type' => 'select', 'options' => ['dark', 'light']],
        ],
    ]);
    
  2. Configuration Storage Store app type configurations in a database table (e.g., app_types) with JSON fields for configurable_fields. Example migration:

    Schema::create('app_types', function (Blueprint $table) {
        $table->id();
        $table->string('name')->unique();
        $table->json('config')->nullable();
        $table->timestamps();
    });
    
  3. Integration with Laravel Controllers Fetch and validate app type configurations in controllers:

    public function store(Request $request, $appTypeName)
    {
        $appType = $this->appTypeRepository->findByName($appTypeName);
        $validated = $request->validate($this->buildValidationRules($appType->config));
    
        // Process validated data...
    }
    
    private function buildValidationRules(array $config): array
    {
        $rules = [];
        foreach ($config['configurable_fields'] ?? [] as $field => $options) {
            $rules[$field] = $options['required'] ? 'required' : 'nullable';
            if (isset($options['type']) && $options['type'] === 'email') {
                $rules[$field] .= '|email';
            }
        }
        return $rules;
    }
    
  4. Dynamic Form Generation Use Blade to render forms based on app type configurations:

    @foreach($appType->config['configurable_fields'] ?? [] as $field => $options)
        <div class="form-group">
            <label for="{{ $field }}">{{ $options['label'] }}</label>
            @if($options['type'] === 'select')
                <select name="{{ $field }}" id="{{ $field }}" class="form-control">
                    @foreach($options['options'] ?? [] as $option)
                        <option value="{{ $option }}">{{ $option }}</option>
                    @endforeach
                </select>
            @elseif($options['type'] === 'text')
                <input type="text" name="{{ $field }}" id="{{ $field }}" class="form-control">
            @endif
        </div>
    @endforeach
    

Patterns for Extensibility

  • Event-Driven Extensions: Subscribe to Domainator9kApptypeGenericEvents to extend behavior (e.g., logging, notifications).
  • Custom Validators: Create form request validators that leverage configurable_fields for dynamic rules.
  • API Endpoints: Expose app type configurations via Laravel API resources:
    Route::get('/app-types/{name}', [AppTypeController::class, 'show']);
    
    public function show($name)
    {
        return new AppTypeResource($this->appTypeRepository->findByName($name));
    }
    

Gotchas and Tips

Pitfalls

  1. Deprecated Bundle

    • Last release in 2018; test thoroughly for compatibility with modern Laravel/Symfony (e.g., PHP 8.x, Symfony 5+).
    • Mitigation: Fork the repository or wrap the bundle in a compatibility layer.
  2. Lack of Documentation

    • No official docs; rely on source code (src/District09/Domainator9kApptypeGenericBundle) for undocumented features.
    • Tip: Use php artisan dump-autoload and inspect the bundle’s Domainator9kApptypeGenericBundle class for methods like registerAppType().
  3. Event Dispatcher Assumption

    • The bundle expects Symfony’s EventDispatcherInterface. In Laravel, use the Symfony bridge:
    use Symfony\Component\EventDispatcher\EventDispatcher;
    $dispatcher = new EventDispatcher();
    
  4. Database Schema Ambiguity

    • No predefined migrations; manually create tables for app_types and related data.
    • Tip: Use Laravel’s Schema::json() for configurable_fields to avoid serialization issues.

Debugging Tips

  • Event Debugging: Dump events in subscribers to verify triggers:
    $dispatcher->addListener(Domainator9kApptypeGenericEvents::APP_TYPE_CREATED, function ($event) {
        \Log::debug('App type created:', ['event' => $event->getAppType()]);
    });
    
  • Configuration Validation: Validate configurable_fields structure early:
    if (!isset($config['configurable_fields'][$field]['type'])) {
        throw new \InvalidArgumentException("Field '$field' requires a 'type'.");
    }
    

Extension Points

  1. Custom App Type Logic Override bundle behavior by extending its core classes (e.g., Domainator9kApptypeGenericEvents):

    class CustomAppTypeEvents extends Domainator9kApptypeGenericEvents
    {
        const APP_TYPE_VALIDATED = 'app_type.validated';
    }
    
  2. Field Type Plugins Add support for custom field types (e.g., date, checkbox) by extending the bundle’s field validation logic.

  3. Laravel Service Provider Integration Bind the bundle’s services to Laravel’s container:

    public function register()
    {
        $this->app->bind(
            District09\Domainator9kApptypeGenericBundle\Domainator9kApptypeGenericBundle::class
        );
    }
    

Performance Considerations

  • Caching App Types: Cache fetched app types to avoid repeated database queries:
    $appType = Cache::remember("app_type.{$name}", now()->addHours(1), function () use ($name) {
        return $this->appTypeRepository->findByName($name);
    });
    
  • JSON Field Indexing: Add database indexes to JSON fields if querying them frequently:
    Schema::table('app_types', function (Blueprint $table) {
        $table->json('config')->index();
    });
    
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.
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui