Installation:
composer require campaignchain/dev-tools
composer update
Add to app/AppKernel.php:
new CampaignChain\GeneratorBundle\CampaignChainGeneratorBundle(),
First Use Case: Run the generator via CLI:
php app/console campaignchain:generate:module
Follow the interactive prompts (module name, identifier, description, vendor details, etc.).
Where to Look First:
php app/console → campaignchain:generate:modulesrc/ for new bundle structure (e.g., Vendor/ModuleBundle/).Prompt-Driven Generation:
campaignchain:generate:module and answer prompts sequentially (e.g., namespace, license, dependencies).Module name [MyModule]: UserManagement
Module identifier [user_management]: user_management
Bundle namespace [CampaignChain\UserManagementBundle]: AppBundle\UserManagementBundle
Composer Integration:
composer.json snippet for the module under Resources/config/composer.json.composer.json or use --composer flag (if supported) to auto-register.Bundle Structure:
src/
├── Vendor/
│ └── ModuleBundle/
│ ├── Controller/
│ ├── DependencyInjection/
│ │ ├── ModuleExtension.php
│ │ └── module.services.yml
│ ├── Resources/
│ │ ├── config/
│ │ │ └── services.yml
│ │ └── views/
│ └── ModuleBundle.php
Extending Generation:
vendor/campaignchain/dev-tools/templates/ to app/Resources/CampaignChainGeneratorBundle/templates/.Post-Generation Tasks:
AppKernel.php:
new Vendor\ModuleBundle\ModuleBundle(),
autoload_psr4.php if namespaces aren’t auto-detected:
'Vendor\\ModuleBundle\\' => [__DIR__.'/../src/Vendor/ModuleBundle'],
Namespace Collisions:
Vendor\ModuleBundle) doesn’t conflict with existing bundles.--namespace flag during generation or manually rename the directory.Composer Autoload Issues:
composer dump-autoload
autoload_psr4.php includes the new namespace.Symfony Version Mismatch:
config/bundles.php.services.yml to use Symfony’s autowiring.Missing Dependencies:
DoctrineBundle), add them to:
composer.json (merge manually).config/bundles.php (Symfony 4+) or AppKernel.php.Template Overrides Not Working:
app/Resources/CampaignChainGeneratorBundle/templates/ match the generator’s expected structure.debug:config to verify paths.--dry-run (if supported) to preview generated files without writing.APP_DEBUG=1) to see generator output:
php app/console campaignchain:generate:module --debug
Custom Templates:
ModuleBundle.php, services.yml) by placing copies in:
app/Resources/CampaignChainGeneratorBundle/templates/
README.md template.Pre/Post-Generation Hooks:
CampaignChain\GeneratorBundle\Generator\ModuleGenerator and overriding methods like generateBundle().services.yml:
campaignchain.generator.module:
class: Your\CustomModuleGenerator
tags: [campaignchain.generator]
Adding New Prompts:
QuestionHelper or adding new options to the CLI command.Composer Script Integration:
post-update-cmd in composer.json to auto-register generated modules:
"scripts": {
"post-update-cmd": [
"php bin/console campaignchain:generate:module --composer"
]
}
How can I help you explore Laravel packages today?