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

Meat Up Laravel Package

daniellehrner/meat-up

Symfony bundle that generates a full CRUD scaffold from a Doctrine entity. Provides a console command to create a controller, FormType, and Twig views (index table plus create/edit pages), based on a Symfony Skeleton starting point.

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Steps to Begin

  1. Installation:

    composer require daniellehrner/meat-up
    

    Ensure your project uses Symfony 2.8 and the interpunkt skeleton.

  2. First Use Case: Generate a CRUD controller for an existing Doctrine entity (e.g., App\Entity\Post):

    php app/console ip:meat-up "App\Entity\Post"
    

    This creates:

    • A FormType (e.g., PostType.php).
    • A CRUD Controller (e.g., PostController.php).
    • Twig templates for index, show, new, and edit actions.
  3. Where to Look First:

    • Entity Annotations: Check Resources/doc/index.md for supported annotations (e.g., @MU\OnIndexPage, @MU\Hidden).
    • Generated Files: Outputs land in src/[Bundle]/Controller/ and src/[Bundle]/Resources/views/.
    • Command Help:
      php app/console ip:meat-up --help
      

Implementation Patterns

Workflows

  1. Entity-First Development:

    • Define your Doctrine entity with annotations (e.g., @MU\OnIndexPage for table columns).
    • Run ip:meat-up to auto-generate CRUD scaffolding.
    • Example:
      /**
       * @ORM\Column(type="string")
       * @MU\OnIndexPage(label="Post Title", filter="upper")
       */
      private $title;
      
  2. Form Customization:

    • Use annotations to control form fields:
      • @MU\Hidden to exclude fields.
      • @MU\CKEditor for rich-text fields.
      • @MU\VichUploadable for file uploads.
    • Override generated FormType classes in src/[Bundle]/Form/ if needed.
  3. Relationships:

    • For ManyToOne, use @MU\ManyToOneOrderBy to sort related entities:
      /**
       * @MU\ManyToOneOrderBy("name")
       */
      private $author;
      
  4. Twig Overrides:

    • Extend templates by copying generated Twig files to src/[Bundle]/Resources/views/Override/ and modifying them.
  5. Command Options:

    • Force overwrite existing files:
      php app/console ip:meat-up "App\Entity\Post" --force
      

Integration Tips

  • Routing: Ensure your routing.yml includes the generated controller paths (e.g., /admin/post).
  • Assets: Use {% block stylesheets %} and {% block javascripts %} in Twig templates to add bundle-specific assets.
  • Validation: Add Symfony validation constraints (e.g., @Assert\NotBlank) to entity properties for automatic form validation.
  • Testing: Test generated controllers with PHPUnit by mocking dependencies (e.g., EntityManager, FormFactory).

Gotchas and Tips

Pitfalls

  1. Lock File Conflicts:

    • The bundle creates a .meatup.lock file to prevent concurrent generation. Delete it manually if stuck:
      rm src/[Bundle]/Resources/.meatup.lock
      
    • Use --force to bypass locks (not recommended for shared environments).
  2. Annotation Namespace:

    • Always use the correct namespace for annotations:
      use Ip\MeatUp\Mapping as MU;
      
    • Forgetting this causes silent failures (no generated output).
  3. Symfony Version Mismatch:

    • The bundle is Symfony 2.8-only. Upgrading to Symfony 3+ may break functionality (e.g., Twig syntax, autowiring).
  4. Doctrine Schema Updates:

    • Run doctrine:schema:update after generating entities to avoid "class not found" errors in the generated CRUD.
  5. CKEditor/VichUploader Dependencies:

    • Ensure IvoryCKEditorBundle and VichUploaderBundle are installed if using their annotations:
      composer require ivory/ckeditor-bundle vich/uploader-bundle
      

Debugging

  • Check Generated Files: Verify files are written to expected paths (e.g., src/[Bundle]/Controller/).
  • Twig Errors: Clear cache after generation:
    php app/console cache:clear
    
  • Annotation Parsing: Use var_dump() in the entity to confirm annotations are loaded (e.g., @MU\OnIndexPage).
  • Command Output: Run with -v for verbose logs:
    php app/console ip:meat-up "App\Entity\Post" -v
    

Extension Points

  1. Custom Templates:

    • Override the default Twig templates by placing copies in src/[Bundle]/Resources/views/Override/.
    • Example: Copy index.html.twig to customize the table layout.
  2. Annotation Extensions:

    • Extend the bundle’s annotation system by creating a custom annotation class in src/[Bundle]/DependencyInjection/ and updating the generator service.
  3. Post-Generation Hooks:

    • Use Symfony’s kernel.request event to modify generated controllers dynamically (e.g., inject services).
  4. Form Events:

    • Subscribe to FORM_PRE_SET_DATA or FORM_POST_SET_DATA in your bundle to alter form behavior:
      $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) {
          // Modify form dynamically
      });
      

Tips

  • Partial Regeneration:
    • Regenerate only the FormType or Controller by deleting specific files and re-running the command.
  • Dry Runs:
    • Test changes locally before deploying by regenerating in a staging environment.
  • Document Annotations:
    • Add PHPDoc comments to entity properties to clarify annotation usage for teammates.
  • Git Ignore:
    • Add generated files to .gitignore if they’re environment-specific:
      /src/[Bundle]/Controller/Generated*
      /src/[Bundle]/Resources/views/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.
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