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

Maker Bundle Laravel Package

devfusion/maker-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to Begin

  1. Installation Add the bundle to your Laravel project via Composer:

    composer require official-dev-fusion/maker-bundle
    

    Register the bundle in config/app.php under the extra.bundles key:

    'bundles' => [
        DevFusion\MakerBundle\DevFusionMakerBundle::class => ['all' => true],
    ],
    
  2. First Command Run the maker:list command to see available generators:

    php artisan maker:list
    

    Example: Generate a CRUD controller and views for a Post entity:

    php artisan maker:generate:crud Post
    
  3. Where to Look First

    • Documentation: Check the GitHub README for basic usage.
    • Commands: Explore maker: commands via php artisan (e.g., maker:generate:model, maker:generate:controller).
    • Templates: Custom templates are stored in config/maker.php under templates; override them in config/packages/dev_fusion/maker.php.

Implementation Patterns

Common Workflows

  1. CRUD Generation Generate a full CRUD stack (model, controller, views, routes, migrations) in one command:

    php artisan maker:generate:crud Post --fields="title:string(255),content:text,published:boolean"
    
    • Customization: Use --fields to define attributes dynamically or pass --template to use a custom template.
  2. Incremental Generation Generate components separately:

    # Model + Migration
    php artisan maker:generate:model Post --fields="title:string(255),slug:uniqueString(191)"
    
    # Controller (with actions)
    php artisan maker:generate:controller PostController --actions="index,store,show,edit,update,destroy"
    
    # Views (Blade templates)
    php artisan maker:generate:views Post --resource
    
  3. Integration with Existing Code

    • Routes: Generated controllers assume standard route naming (/posts). Override in routes/web.php:
      Route::resource('blog/posts', PostController::class);
      
    • Forms: Use Laravel Collective’s Form and Html helpers in generated views (ensure they’re installed).
  4. Custom Templates Extend default templates by copying them from vendor/devfusion/maker-bundle/resources/templates to config/packages/dev_fusion/maker/templates. Modify as needed.

Best Practices

  • Naming Conventions: Stick to Laravel’s conventions (e.g., PostController for Post model) to avoid conflicts.
  • Field Validation: Define validation rules in the --fields argument or override the template’s validation logic.
  • Testing: Test generated code in a staging environment before deploying to production.

Gotchas and Tips

Pitfalls

  1. Template Overrides

    • Issue: Custom templates in config/packages/dev_fusion/maker/templates may not reflect changes until you clear the cache:
      php artisan cache:clear
      
    • Fix: Use maker:refresh to reload templates dynamically:
      php artisan maker:refresh
      
  2. Field Type Mismatches

    • Issue: Incorrect field types (e.g., string(255) vs. string) may break migrations or models.
    • Fix: Validate field syntax with:
      php artisan maker:validate-fields "title:string(255),content:text"
      
  3. Route Conflicts

    • Issue: Generated routes may clash with existing ones (e.g., /posts vs. /blog/posts).
    • Fix: Use --path to specify a custom route prefix:
      php artisan maker:generate:crud Post --path=admin
      
  4. Dependency Hell

    • Issue: The bundle relies on Symfony’s MakerBundle. Conflicts may arise with other packages using similar generators.
    • Fix: Pin versions in composer.json:
      "require": {
          "symfony/maker-bundle": "^1.44",
          "official-dev-fusion/maker-bundle": "^1.0"
      }
      

Debugging Tips

  • Verbose Output: Use -v or -vv flags to debug generator commands:
    php artisan maker:generate:model Post -vv
    
  • Dry Runs: Test changes without writing files by overriding the writeFiles method in custom commands.
  • Log Files: Check storage/logs/laravel.log for template rendering errors.

Extension Points

  1. Custom Commands Extend the bundle by creating a custom command that uses its generator classes:

    use DevFusion\MakerBundle\Generator\Generator;
    
    class CustomGeneratorCommand extends Command {
        protected function handle() {
            $generator = new Generator();
            $generator->generateModel($this->argument('name'), $this->option('fields'));
        }
    }
    
  2. Event Listeners Listen to maker.generated events to post-process generated files:

    use DevFusion\MakerBundle\Event\GeneratedEvent;
    
    public function handle(GeneratedEvent $event) {
        if ($event->getType() === 'model') {
            // Modify the generated model file
        }
    }
    
  3. Configuration Override default settings in config/packages/dev_fusion/maker.php:

    return [
        'namespace' => 'App\\Generated',
        'path' => 'app/Generated',
        'prefix' => 'generated_',
    ];
    
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.
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
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope