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

Draw Bundle Laravel Package

draw/draw-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add the bundle via Composer:

    composer require draw/draw-bundle
    

    Enable it in config/bundles.php:

    return [
        // ...
        Draw\DrawBundle\DrawBundle::class => ['all' => true],
    ];
    
  2. First Use Case: CLI Commands Run the built-in commands to explore functionality:

    php bin/console draw:list  # List available commands
    php bin/console draw:make:controller UserController  # Generate a controller
    
  3. Where to Look First

    • Commands: Check src/Command/ for available CLI tools.
    • Twig Extensions: Review src/Twig/ for reusable Twig helpers.
    • Doctrine Extensions: Inspect src/Doctrine/ for ORM utilities.

Implementation Patterns

CLI Workflows

  • Code Generation Use draw:make:controller, draw:make:entity, or draw:make:form to scaffold boilerplate:

    php bin/console draw:make:controller Admin/DashboardController --resource=Post
    

    Tip: Customize templates in vendor/draw/draw-bundle/Resources/skeleton/.

  • Database Utilities Reset migrations or generate SQL dumps:

    php bin/console draw:db:reset
    php bin/console draw:db:dump --path=./backup.sql
    

Twig Integration

Extend templates with custom filters/extensions:

{{ 'hello'|draw_uppercase }}
{{ draw_asset('css/style.css') }}  {# Optimized asset handling #}

Register in config/packages/draw.yaml:

draw:
    twig:
        extensions: ['App\Twig\CustomExtension']

Doctrine Patterns

  • Entity Helpers Use draw:make:entity with --fields to auto-generate CRUD fields:
    php bin/console draw:make:entity Product --fields="name:string,price:decimal(10,2)"
    
  • Repository Shortcuts Extend base repositories with Draw\Doctrine\BaseRepository.

Configuration

Centralize settings in config/packages/draw.yaml:

draw:
    generators:
        namespace: 'App\\Generator'  # Custom generator namespace
    assets:
        version: 'v1.2'  # Asset cache versioning

Gotchas and Tips

Pitfalls

  • Outdated Package Last release in 2019—verify compatibility with Symfony 5/6/Laravel (if using via Symfony bridge). Override deprecated features with custom logic.

  • Namespace Collisions The bundle’s generators use Draw\ namespace. Prepend your custom generators with App\Generator\ in draw.yaml to avoid conflicts.

  • Twig Cache Issues Clear Twig cache after adding extensions:

    php bin/console cache:clear
    

Debugging

  • Command Errors Run with -v for verbose output:

    php bin/console draw:make:controller -v
    

    Check var/log/dev.log for Doctrine/Twig errors.

  • Asset Pipeline If draw_asset() fails, ensure assets config is set in draw.yaml:

    draw:
        assets:
            base_urls: ['%kernel.project_dir%/public/build']
    

Extension Points

  • Custom Commands Extend existing commands by overriding their classes (e.g., Draw\Command\MakeControllerCommand) in your bundle.

  • Twig Filters Add filters by implementing Twig\Extension\AbstractExtension and registering in draw.yaml:

    draw:
        twig:
            filters:
                - { name: 'custom_filter', class: 'App\Twig\CustomFilter' }
    
  • Doctrine Events Subscribe to draw.entity.generate events to modify entity generation dynamically:

    // config/services.yaml
    services:
        App\EventListener\DrawEntityListener:
            tags:
                - { name: 'kernel.event_listener', event: 'draw.entity.generate', method: 'onGenerate' }
    
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