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],
];
First Command Run the interactive bundle generator:
php bin/console darkwood:generate:bundle
Follow prompts to scaffold a new bundle (e.g., App\MyBundle).
Key Files
src/Darkwood/GeneratorBundle/Resources/config/services.xml: Core command definitions.src/Darkwood/GeneratorBundle/Generator/: Base generator classes (extend for custom logic).Generate a CRUD Controller
php bin/console darkwood:generate:crud App\Entity\Post
src/Controller/PostController.php)src/Form/PostType.php)templates/post/)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'
Doctrine Schema Integration
Use --with-doctrine flag to auto-detect entities:
php bin/console darkwood:generate:form App\Entity\Post --with-doctrine
darkwood.generator.event_listener service tag.
Example:
services:
App\EventListener\CustomGeneratorListener:
tags:
- { name: 'darkwood.generator.event_listener', priority: 100 }
Darkwood\GeneratorBundle\Command\GenerateCommand for custom logic.Archived Status
sensio/generator-bundle for production use.Doctrine Dependency
composer require doctrine/orm
Template Overrides
--verbose flag:
php bin/console darkwood:generate:bundle --verbose
--dry-run to preview changes without writing files:
php bin/console darkwood:generate:form App\Entity\Post --dry-run
var/log/dev.log for generator errors.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.
Dynamic Prompts
Override Darkwood\GeneratorBundle\Command\InteractiveCommand to add custom questions:
protected function configureInputDefinition() {
$this->inputDefinition->addOption('custom-option');
}
How can I help you explore Laravel packages today?