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

Bundle Generator Bundle Laravel Package

dktaylor/bundle-generator-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation Run composer require dktaylor/bundle-generator-bundle in your Symfony project root. Ensure config/bundles.php includes the bundle (auto-registered via Flex if present).

  2. First Use Case Generate a new bundle skeleton:

    php bin/console make:bundle MyVendor/MyBundle
    

    This creates a standalone bundle in ../MyVendor/MyBundle (one level up) and symlinks it to lib/MyVendor/MyBundle.

  3. Where to Look First

    • Console Commands: php bin/console list → Filter for make:bundle and related commands.
    • Configuration: Check config/packages/dktaylor_bundle_generator.yaml (if any).
    • Templates: Default templates are in vendor/dktaylor/bundle-generator-bundle/Resources/skeleton.

Implementation Patterns

Workflows

  1. Bundle Development Loop

    • Generate: make:bundle MyVendor/MyBundle
    • Iterate: Edit files in ../MyVendor/MyBundle, symlink updates auto-propagate.
    • Test: Use make:test (if configured) or manually load the bundle in Symfony’s kernel.
  2. Custom Templates Override defaults by copying vendor/dktaylor/bundle-generator-bundle/Resources/skeleton to config/bundles/skeleton/ and extending the base class:

    # config/packages/dktaylor_bundle_generator.yaml
    dktaylor_bundle_generator:
        skeleton_dir: '%kernel.project_dir%/config/bundles/skeleton'
    
  3. Integration with Symfony Flex

    • Auto-discovery: New bundles appear in config/bundles.php after generation.
    • Recipes: Extend with custom recipes (e.g., make:bundle --recipe=my-recipe).
  4. Multi-Bundle Projects Use --path to generate bundles in arbitrary locations:

    make:bundle MyVendor/MyBundle --path=~/Projects/bundles
    

Pro Tips

  • Symlink Management: Run composer dump-autoload after symlinking to refresh autoloading.
  • CI/CD: Add a post-generate step to validate symlinks:
    find lib -type l -exec test -e {} \; || exit 1
    
  • Dependency Injection: Use make:bundle --with-services to auto-generate DI configurations.

Gotchas and Tips

Pitfalls

  1. Symlink Issues

    • Problem: Broken symlinks if the source directory is moved/deleted.
    • Fix: Use absolute paths or verify symlinks with ls -l lib/.
    • Debug: Run composer dump-autoload --optimize to force a refresh.
  2. Namespace Collisions

    • Problem: Generating Vendor/Bundle when Vendor already exists in vendor/ (not lib/).
    • Fix: Prefer lib/ for local bundles or use unique vendor names (e.g., MyCompany/).
  3. Template Overrides

    • Problem: Custom templates not picked up.
    • Fix: Ensure skeleton_dir in config points to a valid directory with a Bundle class extending BaseBundle.
  4. Flex Auto-Configuration

    • Problem: Bundle not auto-registered in bundles.php.
    • Fix: Manually add to config/bundles.php or run composer dump-autoload.

Debugging

  • Command Errors: Use --verbose:
    make:bundle MyVendor/MyBundle --verbose
    
  • Bundle Loading: Check Symfony’s debug toolbar or run:
    php bin/console debug:container | grep MyBundle
    
  • Logs: Enable debug mode (APP_ENV=dev) and check var/log/dev.log.

Extension Points

  1. Custom Commands Extend the generator with new commands by creating a Command class in your bundle and tagging it:

    services:
        MyVendor\MyBundle\Command\MyCommand:
            tags: ['console.command']
    
  2. Event Subscribers Hook into bundle generation events (if the package supports them) via:

    use DKTaylor\BundleGeneratorBundle\Event\BundleGenerateEvent;
    use Symfony\Component\EventDispatcher\EventSubscriberInterface;
    
    class MySubscriber implements EventSubscriberInterface {
        public static function getSubscribedEvents() {
            return [
                BundleGenerateEvent::NAME => 'onBundleGenerate',
            ];
        }
    }
    
  3. Post-Generation Scripts Add a post-generate script in composer.json to run custom tasks:

    "scripts": {
        "post-autoload-dump": [
            "@post-generate",
            "symlink-bundles"
        ],
        "post-generate": [
            "php bin/console my:post-bundle-setup"
        ]
    }
    

Config Quirks

  • Default Path: Bundles generate one level up from the project root. Change this by overriding skeleton_dir in config.
  • Flex Compatibility: If using Symfony Flex, ensure composer.json has "extra": { "symfony": { "allow-contrib": true } }.
  • Case Sensitivity: Bundle names are case-sensitive in bundles.php (e.g., MyVendor/MyBundlemyvendor/mybundle).
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.
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium