Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Adminlte Generator Bundle Laravel Package

aleste/adminlte-generator-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation

    composer require aleste/adminlte-generator-bundle
    

    Add to config/bundles.php:

    return [
        // ...
        Aleste\AdminLteGeneratorBundle\AlesteAdminLteGeneratorBundle::class => ['all' => true],
    ];
    
  2. 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.

  3. Key Files to Review

    • config/packages/adminlte_generator.yaml (default config)
    • src/Controller/ (auto-generated CRUD controllers)
    • templates/adminlte/ (AdminLTE-specific Twig templates)

Implementation Patterns

Core Workflows

  1. 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.
  2. Customizing AdminLTE Templates Override default templates by copying from:

    vendor/aleste/adminlte-generator-bundle/Resources/views/adminlte/
    

    to:

    templates/adminlte/
    
  3. Integration with Existing Projects

    • Doctrine Entities: Works with any Doctrine entity (no annotations required).
    • Forms: Auto-generates Symfony forms with AdminLTE-compatible field types (e.g., select2, datetimepicker).
    • Routes: Generates RESTful routes under /admin/{entity} (configurable in config/routes.yaml).
  4. 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
    
  5. AdminLTE-Specific Features

    • Boxes: Auto-generates AdminLTE boxes for each CRUD section.
    • Widgets: Includes common widgets (e.g., charts, quick stats) via --with-widgets.
    • Sidebar: Dynamically updates the sidebar menu based on generated CRUDs.

Integration Tips

  • Knplabs Paginator: Pre-configured for pagination in list views.
  • LexikFormFilter: Enable filtering with --with-filter and customize in config/packages/lexik_form_filter.yaml.
  • Custom Fields: Extend the generator by creating a custom field type:
    # config/packages/adminlte_generator.yaml
    aleste_adminlte_generator:
        fields:
            custom_field:
                type: 'custom'
                template: 'adminlte/custom_field.html.twig'
    
  • Assets: AdminLTE CSS/JS is auto-included via base.html.twig. Override in templates/adminlte/layouts/base.html.twig.

Gotchas and Tips

Pitfalls

  1. Symfony Version Mismatch

    • The bundle requires Symfony 2.8–3.0. For Symfony 4/5, use a fork or wrapper bundle.
    • Fix: Check composer.json requirements and update dependencies if needed.
  2. Doctrine Metadata Issues

    • If the entity lacks metadata (e.g., no @ORM\Table), the generator may fail.
    • Fix: Ensure entities are properly mapped or use --force flag:
      php bin/console generate:crud --entity=User --force
      
  3. Template Overrides Not Loading

    • Custom templates in templates/adminlte/ may not reflect changes.
    • Fix: Clear cache:
      php bin/console cache:clear
      
    • Verify Twig paths in config/packages/twig.yaml include your templates/ directory.
  4. Route Conflicts

    • Default routes (/admin/{entity}) may clash with existing routes.
    • Fix: Customize the route prefix in config/packages/adminlte_generator.yaml:
      aleste_adminlte_generator:
          route_prefix: 'backend'
      
  5. AdminLTE Assets Missing

    • If AdminLTE CSS/JS fails to load, the bundle assumes assets are installed via Bower or npm.
    • Fix: Manually include AdminLTE assets in base.html.twig or use a package like adminlte-bundle.

Debugging

  • Verbose Output: Run commands with -v for debug logs:
    php bin/console generate:crud --entity=Product -v
    
  • Generator Events: Listen for events to customize generation:
    // 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');
        }
    }
    

Extension Points

  1. 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'
    
  2. 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'
    
  3. 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'
    
  4. 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'
    
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
comsave/common
alecsammon/php-raml-parser
chrome-php/wrench
lendable/composer-license-checker
typhoon/reflection
mesilov/moneyphp-percentage
mike42/gfx-php
bookdown/themes
aura/view
aura/html
aura/cli
povils/phpmnd
nayjest/manipulator
omnipay/tests
psr-mock/http-message-implementation
psr-mock/http-factory-implementation
psr-mock/http-client-implementation
voku/email-check
voku/urlify
rtheunissen/guzzle-log-middleware