appventus/auto-form-fill-bundle
Installation:
composer require-dev appventus/auto-form-fill-bundle
Add to AppKernel.php (Symfony 2.x):
if (in_array($this->getEnvironment(), ['dev'])) {
$bundles[] = new AppVentus\AutoFormFillBundle\AvAutoFormFillBundle();
}
First Use Case:
http://your-app.dev/user/new).dev mode.Dev-Only Activation:
dev environment (via AppKernel). Disable in prod/test to avoid side effects.Form Field Handling:
FormType components (e.g., TextType, DateType).av_autoformfill_skip (e.g., password, token).Testing Workflow:
Customization:
FormFiller service (see Gotchas for details).services.yml:
services:
av_autoformfill.form_filler:
arguments:
- ['@custom_faker_provider']
Environment Leaks:
Field Selection Issues:
FormFiller class to include them:
// src/AppVentus/AutoFormFillBundle/DependencyInjection/Compiler/FakerPass.php
public function process(ContainerBuilder $container) {
$definition = $container->findDefinition('av_autoformfill.form_filler');
$definition->replaceArgument(0, ['@faker', '@custom_provider']);
}
Faker Limitations:
EntityType fields).FormFiller service to handle custom types:
class CustomFormFiller extends FormFiller {
protected function getFakeDataForType($type, $options) {
if ($type === 'custom_entity') {
return $this->faker->randomElement(['value1', 'value2']);
}
return parent::getFakeDataForType($type, $options);
}
}
Symfony 3+/4+ Compatibility:
symfony/form to ^4.0).AppKernel registration with config/bundles.php:
if ($_ENV['APP_ENV'] === 'dev') {
return [AvAutoFormFillBundle::class];
}
Verify Activation:
dev mode by inspecting the Symfony profiler or logs.AutoFormFillBundle in php bin/console debug:container | grep autoformfill.Log Fake Data:
APP_DEBUG=1) to see which fields are being filled:
// In a controller or event subscriber
$this->get('av_autoformfill.form_filler')->debugMode(true);
Exclude Specific Forms:
#[AutoFormFillSkip]
class MyFormType extends AbstractType { ... }
(Requires extending the bundle’s compiler pass.)Custom Faker Providers:
FormFiller service:
# config/services.yaml
services:
custom.faker.provider:
class: App\Service\CustomFakerProvider
tags:
- { name: av_autoformfill.faker_provider }
Event Listeners:
// src/EventListener/AutoFormFillListener.php
class AutoFormFillListener {
public function onFormPreSetData(FormEvent $event) {
if ($event->getForm()->getConfig()->getType()->getName() === 'app_custom_form') {
$event->setData(['custom_field' => 'hardcoded_value']);
}
}
}
Register the listener in services.yaml:
services:
App\EventListener\AutoFormFillListener:
tags:
- { name: kernel.event_listener, event: form.PRE_SET_DATA, method: onFormPreSetData }
Configuration Overrides:
config/packages/av_autoformfill.yaml:
av_autoformfill:
skip_fields: ['password', 'token', 'av_autoformfill_skip_*']
debug: '%kernel.debug%'
How can I help you explore Laravel packages today?