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

corponat/maker-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps

  1. Installation Add the bundle via Composer:

    composer require symfony/maker-bundle --dev
    

    Enable it in config/bundles.php:

    return [
        // ...
        Symfony\MakerBundle\MakerBundle::class => ['dev' => true, 'test' => true],
    ];
    
  2. First Command Run the make:auth command to scaffold a full authentication system:

    php bin/console make:auth
    

    Follow prompts to configure (e.g., user entity, registration, login).

  3. Where to Look First

    • Documentation: Symfony MakerBundle Docs
    • Commands: Run php bin/console list make to see all available commands.
    • Generated Code: Check src/ for new files after running a command.

Implementation Patterns

Usage Patterns

  1. CRUD Generation Create a controller, repository, and form for an entity in one command:

    php bin/console make:crud Product --field="name:string(255)" --field="price:decimal(10,2)"
    
    • Workflow: Define fields interactively or via CLI arguments, then customize templates in templates/ (if needed).
  2. Event Subscribers Generate a subscriber for a specific event (e.g., KernelEvents::TERMINATE):

    php bin/console make:subscriber MySubscriber --event=kernel.terminate
    
    • Integration Tip: Use subscribers for cross-cutting concerns like logging or caching.
  3. Custom Commands Extend existing commands or create new ones by overriding templates in:

    vendor/symfony/maker-bundle/Resources/skeleton/
    

    Copy templates to templates/ in your project and modify them.

  4. Form Classes Generate a form for an entity with validation rules:

    php bin/console make:form ProductType --fields="name:string|required" --fields="price:decimal(10,2)|nullable"
    
    • Tip: Use --fields to define constraints (e.g., email|required|email).
  5. Doctrine Extensions Scaffold a custom Doctrine extension (e.g., for soft deletes):

    php bin/console make:doctrine-extension SoftDeleteable
    

Workflows

  • Iterative Development: Use make:entity to add fields to an entity, then regenerate CRUD:

    php bin/console make:entity Product --add
    php bin/console make:crud Product --regenerate
    
  • Testing: Generate test classes alongside entities/controllers:

    php bin/console make:test Product
    
    • Tip: Use --test-class to specify a custom test class name.
  • API Resources: Generate API Platform resources with:

    php bin/console make:api-resource Product
    

Gotchas and Tips

Pitfalls

  1. Generated Code Overwrites

    • Running a command on an existing class overwrites it. Use --regenerate carefully.
    • Solution: Back up files or use git diff before regenerating.
  2. Template Conflicts

    • Custom templates in templates/ may conflict with upstream updates.
    • Solution: Merge changes manually or use --no-interaction to avoid prompts.
  3. Doctrine Metadata Cache

    • After regenerating entities, clear the cache:
      php bin/console cache:clear
      php bin/console doctrine:cache:clear-metadata
      
  4. PHP Version Compatibility

    • Some commands (e.g., make:message) require PHP 8.1+. Check the docs for version-specific features.
  5. Environment Restrictions

    • Commands only work in dev or test environments by default (configured in bundles.php).
    • Workaround: Temporarily switch environments or use --env=dev:
      php bin/console make:crud Product --env=dev
      

Debugging

  • Dry Runs: Use --dry-run to preview changes without generating files:
    php bin/console make:crud Product --dry-run
    
  • Verbose Output: Add -v for detailed logs:
    php bin/console make:entity Product -v
    
  • Template Debugging: Enable debug mode in config/packages/dev/maker.yaml:
    maker:
        debug: true
    

Tips

  1. Custom Field Types Extend the bundle to support custom field types by creating a FieldType class and updating the maker.yaml config:

    maker:
        field_types:
            custom_type: App\Maker\CustomFieldType
    
  2. Interactive Prompts Use --no-interaction for scripting or CI/CD:

    php bin/console make:entity Product --no-interaction --field="name:string"
    
  3. Partial Regeneration Regenerate only specific parts (e.g., tests) of a CRUD:

    php bin/console make:crud Product --regenerate-tests
    
  4. Symfony Flex Autoloader If using Symfony Flex, ensure autoloading is configured in composer.json:

    "autoload-dev": {
        "psr-4": {
            "App\\": "src/"
        }
    }
    
  5. Backward Compatibility

    • Generated code may change between minor versions. Use composer why symfony/maker-bundle to track updates.
    • Mitigation: Pin the version in composer.json if stability is critical.
  6. IDE Integration

    • Add vendor/symfony/maker-bundle/Resources/skeleton/ to your IDE’s "Exclude Paths" to avoid clutter.
    • Use // @maker-generated comments to mark auto-generated code (helps with future merges).
  7. Performance

    • For large projects, regenerate commands in batches to avoid long waits.
    • Example: Generate entities first, then CRUD, then tests.
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui