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

Sensio Generator Bundle Laravel Package

kunstmaan/sensio-generator-bundle

Symfony bundle adding interactive CLI generators to scaffold code like bundles, forms, and CRUD controllers from Doctrine 2 schemas. Note: deprecated for modern Symfony—no Symfony 4/Flex support; use Symfony MakerBundle instead.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps for Laravel Integration

  1. Installation (Symfony Context Only)

    composer require kunstmaan/sensio-generator-bundle
    

    Note: This bundle is not natively Laravel-compatible. Use only in Symfony 5/6 projects or as a standalone CLI tool.

  2. First Use Case: CRUD Generation For a Symfony project, generate a CRUD controller for an existing Doctrine entity:

    php bin/console generate:crud
    
    • Follow prompts to select an entity (e.g., User).
    • Outputs: Controller, Twig templates, and form classes in src/App/Controller/.
  3. Where to Look First

    • Commands: List available generators:
      php bin/console list
      
      Key commands:
      • generate:bundle (creates a new bundle skeleton)
      • generate:doctrine:crud (CRUD for Doctrine entities)
      • generate:form (creates a form class)
    • Templates: Customize generation logic in: vendor/kunstmaan/sensio-generator-bundle/Resources/views/.
    • Configuration: Override defaults in config/packages/kunstmaan_sensio_generator.yaml (if using Symfony).

Implementation Patterns

Workflows

  1. Interactive CLI Generation

    • Use generate:crud for full-stack CRUD:
      php bin/console generate:doctrine:crud User
      
      • Generates:
        • Controller (UserController.php)
        • Twig templates (templates/user/)
        • Form class (UserType.php)
        • Routes (config/routes.yaml)
  2. Batch Generation

    • Generate multiple entities via a script:
      php bin/console generate:doctrine:crud Product --no-interaction
      php bin/console generate:doctrine:crud Category --no-interaction
      
  3. Form-Centric Development

    • Scaffold forms without controllers:
      php bin/console generate:form App\Entity\User
      
      • Outputs: UserType.php with validation rules.
  4. Bundle Creation

    • Generate a new bundle skeleton:
      php bin/console generate:bundle --namespace=Acme/DemoBundle --format=yml
      
      • Outputs: src/Acme/DemoBundle/ with standard structure.

Integration Tips

  • Symfony Projects:

    • Pair with DoctrineFixturesBundle for test data:
      php bin/console doctrine:fixtures:load
      
    • Use WebProfilerBundle to debug generated controllers.
  • Customization:

    • Override templates by copying files from: vendor/kunstmaan/sensio-generator-bundle/Resources/views/ to config/packages/kunstmaan_sensio_generator/templates/.
  • CI/CD:

    • Automate generation in pipelines (e.g., GitHub Actions):
      - name: Generate CRUD
        run: php bin/console generate:doctrine:crud User --no-interaction
      

Gotchas and Tips

Pitfalls

  1. Symfony-Only Features

    • Doctrine Dependency: Generates Doctrine-specific code (e.g., Repository, Entity). Not compatible with Laravel Eloquent.
    • Twig Templates: Outputs Twig files (*.twig), which require Symfony’s Twig integration. Laravel uses Blade.
  2. Version Conflicts

    • Symfony 6+: Last release (3.7.0) supports Symfony 6 but may conflict with older Laravel-integrated Symfony components (e.g., symfony/console).
    • PHP 8.1+: Some commands may fail on newer PHP versions due to deprecated Twig features.
  3. File Overwrites

    • Commands overwrite existing files without warnings. Use --dry-run to preview changes:
      php bin/console generate:crud --dry-run
      
  4. Namespace Collisions

    • Generated controllers use Symfony’s App\Controller namespace. Conflict risk if Laravel uses a custom namespace (e.g., App\Http\Controllers).

Debugging

  • Command Errors:
    • Check var/log/dev.log for Symfony errors.
    • Enable verbose output:
      php bin/console generate:crud -v
      
  • Template Issues:
    • Validate Twig syntax in generated templates (e.g., {% extends %} blocks).
    • Clear cache after template changes:
      php bin/console cache:clear
      

Extension Points

  1. Custom Templates

    • Extend templates by copying from: vendor/kunstmaan/sensio-generator-bundle/Resources/views/ to config/packages/kunstmaan_sensio_generator/templates/.
    • Example: Override crud/index.html.twig for custom layouts.
  2. New Commands

    • Create a custom command extending Sensio\Bundle\GeneratorBundle\Command\GenerateCommand:
      // src/Command/CustomGenerateCommand.php
      use Sensio\Bundle\GeneratorBundle\Command\GenerateCommand;
      use Sensio\Bundle\GeneratorBundle\Generator\Generator;
      
      class CustomGenerateCommand extends GenerateCommand {
          protected function configure() {
              $this->setName('app:generate:custom');
          }
          protected function execute(InputInterface $input, OutputInterface $output) {
              $this->generateCustomClass($output);
          }
      }
      
  3. Post-Generation Hooks

    • Use Symfony events to run logic after generation:
      # config/services.yaml
      services:
          App\EventListener\PostGenerateListener:
              tags:
                  - { name: kernel.event_listener, event: sensio_generator.post_generate, method: onPostGenerate }
      

Laravel-Specific Quirks

  • Artisan Integration:
    • To use this bundle in Laravel, wrap commands in a Symfony microkernel or use it as a standalone CLI tool (not recommended for production Laravel apps).
  • Alternative for Laravel:
    • Replace with Laravel’s native generators:
      php artisan make:controller ProductController --resource
      php artisan make:model Product -m
      
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.
nasirkhan/laravel-sharekit
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony