aleste/adminlte-generator-bundle
Installation
composer require aleste/adminlte-generator-bundle
Add to config/bundles.php:
return [
// ...
Aleste\AdminLteGeneratorBundle\AlesteAdminLteGeneratorBundle::class => ['all' => true],
];
First Command
Generate a CRUD for an existing entity (e.g., App\Entity\Product):
php bin/console generate:crud --entity=Product --format=adminlte
Follow prompts to configure routes, form fields, and AdminLTE-specific options.
Key Files to Review
config/packages/adminlte_generator.yaml (default config)src/Controller/ (auto-generated CRUD controllers)templates/adminlte/ (AdminLTE-specific Twig templates)Interactive CRUD Generation Use the CLI to scaffold CRUD with AdminLTE UI:
php bin/console generate:crud --entity=User --format=adminlte --with-write
--with-write: Includes create/update actions.--with-filter: Adds LexikFormFilterBundle integration.Customizing AdminLTE Templates Override default templates by copying from:
vendor/aleste/adminlte-generator-bundle/Resources/views/adminlte/
to:
templates/adminlte/
Integration with Existing Projects
select2, datetimepicker)./admin/{entity} (configurable in config/routes.yaml).Batch Generation Generate multiple CRUDs via a script:
php bin/console generate:crud --entity=Product --format=adminlte --no-interaction
php bin/console generate:crud --entity=Order --format=adminlte --no-interaction
AdminLTE-Specific Features
--with-widgets.--with-filter and customize in config/packages/lexik_form_filter.yaml.# config/packages/adminlte_generator.yaml
aleste_adminlte_generator:
fields:
custom_field:
type: 'custom'
template: 'adminlte/custom_field.html.twig'
base.html.twig. Override in templates/adminlte/layouts/base.html.twig.Symfony Version Mismatch
composer.json requirements and update dependencies if needed.Doctrine Metadata Issues
@ORM\Table), the generator may fail.--force flag:
php bin/console generate:crud --entity=User --force
Template Overrides Not Loading
templates/adminlte/ may not reflect changes.php bin/console cache:clear
config/packages/twig.yaml include your templates/ directory.Route Conflicts
/admin/{entity}) may clash with existing routes.config/packages/adminlte_generator.yaml:
aleste_adminlte_generator:
route_prefix: 'backend'
AdminLTE Assets Missing
base.html.twig or use a package like adminlte-bundle.-v for debug logs:
php bin/console generate:crud --entity=Product -v
// src/EventSubscriber/AdminLteGeneratorSubscriber.php
use Aleste\AdminLteGeneratorBundle\Event\GenerateEvent;
class AdminLteGeneratorSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
GenerateEvent::PRE_GENERATE => 'onPreGenerate',
];
}
public function onPreGenerate(GenerateEvent $event)
{
$event->setOption('route_prefix', 'custom_prefix');
}
}
Custom Field Types
Extend the bundle by adding new field types in config/packages/adminlte_generator.yaml:
aleste_adminlte_generator:
fields:
my_custom_field:
type: 'text'
options:
attr:
class: 'my-custom-class'
Post-Generation Hooks
Use Symfony’s kernel.terminate event to run scripts after generation:
// config/services.yaml
App\Command\PostGenerateCommand:
tags: ['console.command']
arguments:
$generator: '@aleste_adminlte_generator.generator'
AdminLTE Configuration
Override AdminLTE settings (e.g., skin, layout) in config/packages/adminlte_generator.yaml:
aleste_adminlte_generator:
adminlte:
skin: 'skin-blue'
layout: 'layout-boxed'
Localization Translate labels and messages by extending the bundle’s translation catalog:
php bin/console translation:update --dir=translations --force
Add translations to translations/messages.en.yaml:
'action.edit': 'Custom Edit Label'
How can I help you explore Laravel packages today?