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

Generator Bundle Laravel Package

darkwood/generator-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the bundle to composer.json:

    composer require darkwood/generator-bundle
    

    Register the bundle in config/bundles.php:

    return [
        // ...
        Darkwood\GeneratorBundle\DarkwoodGeneratorBundle::class => ['all' => true],
    ];
    
  2. First Command Run the interactive bundle generator:

    php bin/console darkwood:generate:bundle
    

    Follow prompts to scaffold a new bundle (e.g., App\MyBundle).

  3. Key Files

    • src/Darkwood/GeneratorBundle/Resources/config/services.xml: Core command definitions.
    • src/Darkwood/GeneratorBundle/Generator/: Base generator classes (extend for custom logic).

Implementation Patterns

Workflow: CRUD Generation

  1. Generate a CRUD Controller

    php bin/console darkwood:generate:crud App\Entity\Post
    
    • Auto-generates:
      • Controller (src/Controller/PostController.php)
      • Form types (src/Form/PostType.php)
      • Twig templates (templates/post/)
  2. Customize Templates Override default templates by copying files from:

    vendor/darkwood/generator-bundle/Resources/skeleton/
    

    to:

    config/packages/darkwood_generator.yaml
    

    Example:

    darkwood_generator:
        templates:
            crud: '%kernel.project_dir%/templates/custom_crud'
    
  3. Doctrine Schema Integration Use --with-doctrine flag to auto-detect entities:

    php bin/console darkwood:generate:form App\Entity\Post --with-doctrine
    

Integration Tips

  • Event Listeners: Extend generators via darkwood.generator.event_listener service tag. Example:
    services:
        App\EventListener\CustomGeneratorListener:
            tags:
                - { name: 'darkwood.generator.event_listener', priority: 100 }
    
  • Command Customization: Subclass Darkwood\GeneratorBundle\Command\GenerateCommand for custom logic.

Gotchas and Tips

Pitfalls

  1. Archived Status

    • The package is archived (no active maintenance). Prefer sensio/generator-bundle for production use.
    • Risk: Unresolved issues or breaking changes in newer Symfony versions.
  2. Doctrine Dependency

    • Requires Doctrine ORM. Fails silently if not installed. Verify with:
      composer require doctrine/orm
      
  3. Template Overrides

    • Overriding templates requires exact directory structure. Miss a file? Generation skips it.
    • Debug with --verbose flag:
      php bin/console darkwood:generate:bundle --verbose
      

Debugging

  • Dry Run: Use --dry-run to preview changes without writing files:
    php bin/console darkwood:generate:form App\Entity\Post --dry-run
    
  • Log Output: Check var/log/dev.log for generator errors.

Extension Points

  1. Custom Generators Extend Darkwood\GeneratorBundle\Generator\Generator:

    namespace App\Generator;
    
    use Darkwood\GeneratorBundle\Generator\Generator;
    
    class MyCustomGenerator extends Generator {
        protected function configure() { ... }
        protected function generate() { ... }
    }
    

    Register as a service with the darkwood.generator tag.

  2. Dynamic Prompts Override Darkwood\GeneratorBundle\Command\InteractiveCommand to add custom questions:

    protected function configureInputDefinition() {
        $this->inputDefinition->addOption('custom-option');
    }
    
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui