cedriclombardot/admingenerator-activeadmintheme-bundle
Installation
Add the bundle to your composer.json:
composer require cedriclombardot/admingenerator-activeadmintheme-bundle
Enable it in config/bundles.php:
return [
// ...
CedricLombardot\AdmingeneratorActiveAdminThemeBundle\CedricLombardotAdmingeneratorActiveAdminThemeBundle::class => ['all' => true],
];
Basic Configuration
Ensure your config/packages/admingenerator.yaml includes:
theme: active_admin
First Use Case
Generate a CRUD interface for an existing entity (e.g., User):
php bin/console generate:doctrine:crud --entity=App\Entity\User --theme=active_admin
Navigate to /admin/user to see the ActiveAdmin-style interface.
Theme Integration
templates/admingenerator/active_admin/.edit.html.twig for a model by copying vendor/cedriclombardot/admingenerator-activeadmintheme-bundle/Resources/views/active_admin/edit.html.twig to your project’s templates/ directory.Dynamic Configuration Use YAML or PHP config to tweak ActiveAdmin behavior per entity:
# config/packages/admingenerator.yaml
active_admin:
User:
dashboard: true
batch_actions: ['delete']
Asset Management
assets/admingenerator/active_admin/.assets/admingenerator/active_admin/css/custom.css and reference it in your base template.Form Customization Leverage Twig extensions to modify forms dynamically:
{{ form_widget(form.field, {'attr': {'data-custom': 'value'}}) }}
Permissions & Security
Integrate with Symfony’s security system via access_control in admingenerator.yaml:
access_control:
User:
edit: ROLE_ADMIN
delete: ROLE_SUPER_ADMIN
Template Overrides
templates/admingenerator/active_admin/ (not templates/admingenerator/ directly) to avoid conflicts.Asset Pipeline
assets/admingenerator/active_admin/ and enqueue them in base.html.twig:
{{ encore_entry_link_tags('admingenerator-active-admin') }}
Form Type Conflicts
config/packages/twig.yaml:
twig:
form_themes: ['admingenerator/active_admin/form.html.twig']
Translation Keys
translations/messages.en.yaml:
admingenerator:
active_admin:
user:
email: "Email Address"
Debugging
config/packages/dev/twig.yaml:
twig:
debug: true
strict_variables: true
Custom Actions
Add custom actions (e.g., "Export") by creating a service tagged as admingenerator.action:
# config/services.yaml
services:
App\Generator\Action\ExportAction:
tags: ['admingenerator.action']
Event Listeners
Hook into the generator lifecycle via events (e.g., admingenerator.generate):
// src/EventListener/AdmingeneratorListener.php
public function onGenerate(GenerateEvent $event) {
$event->setTheme('active_admin');
}
Dynamic Filters
Extend the filter system by creating a custom filter class and registering it in admingenerator.yaml:
filters:
User:
- { name: 'active', type: 'boolean' }
How can I help you explore Laravel packages today?