Installation:
composer require ano/generator-bundle
Ensure your AppKernel.php includes the bundle:
new Ano\GeneratorBundle\AnoGeneratorBundle(),
First Use Case:
php bin/console ano:generator:list
php bin/console ano:generator:generate controller --name=TestController
Where to Look First:
ano:generator:* commands in bin/console.vendor/ano/generator-bundle/Resources/templates/.config/packages/ano_generator.yaml (if supported).Template-Based Generation:
php bin/console ano:generator:generate crud --entity=User --bundle=AppBundle
Custom Templates:
src/AnoGeneratorBundle/Resources/templates/ (or a custom namespace).GeneratorService to inject your templates.Integration with Existing Code:
Parameterized Generation:
php bin/console ano:generator:generate service --name=UserService --interface=UserInterface
AppBundle\Entity).Template Overrides:
Resources/templates/generators/).composer dump-autoload).Symfony 4+ Compatibility:
"symfony/framework-bundle":"2.*"). For Symfony 4/5/6:
flex or manually configure the bundle in config/bundles.php.AppKernel.php registration with:
// config/bundles.php
return [
// ...
Ano\GeneratorBundle\AnoGeneratorBundle::class => ['all' => true],
];
Dependency Injection:
twig, filesystem) are available.GeneratorService to inject custom dependencies:
# config/services.yaml
services:
App\Custom\GeneratorService:
decorates: 'ano.generator.service'
arguments: ['@App\Custom\GeneratorService.inner']
File Conflicts:
--force cautiously:
php bin/console ano:generator:generate --force
php bin/console ano:generator:generate --debug
php bin/console debug:twig
var/log/dev.log for generation errors.New Generators:
AnoGeneratorBundle\Command\GeneratorCommand.use Ano\GeneratorBundle\Command\GeneratorCommand;
class CustomGeneratorCommand extends GeneratorCommand {
protected function configure() {
$this->setName('ano:custom:generate');
}
}
Dynamic Templates:
include to modularize templates:
{# src/AnoGeneratorBundle/Resources/templates/custom.twig #}
{% include 'base.twig' %}
Post-Generation Hooks:
GeneratorService to run post-generation tasks (e.g., database migrations):
public function generate($template, array $params) {
$result = parent::generate($template, $params);
$this->postGenerateHook($result);
return $result;
}
How can I help you explore Laravel packages today?