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

Media Bundle Laravel Package

bigfoot/media-bundle

View on GitHub
Deep Wiki
Context7

Getting Started

Minimal Setup

  1. Installation Add to composer.json:

    "require": {
        "c2is/bigfoot-media-bundle": "dev-master"
    }
    

    Run composer update and enable in AppKernel.php:

    new C2is\BigfootMediaBundle\BigfootMediaBundle(),
    
  2. Configuration Update config.yml with your storage paths:

    bigfoot_media:
        upload_dir: "%kernel.root_dir%/../web/uploads"
        thumbnail_dir: "%kernel.root_dir%/../web/uploads/thumbs"
    
  3. First Use Case Create a form type with media upload handling:

    use C2is\BigfootMediaBundle\Form\Type\MediaType;
    
    $builder->add('media', MediaType::class);
    

Implementation Patterns

Common Workflows

  1. File Upload Handling Use MediaType in forms to auto-generate upload fields:

    $form = $this->createFormBuilder($entity)
        ->add('image', MediaType::class, [
            'label' => 'Profile Image',
            'allowed_mime_types' => ['image/jpeg', 'image/png']
        ])
        ->getForm();
    
  2. Thumbnail Generation Configure via YAML:

    bigfoot_media:
        thumbnail_sizes: [100x100, 200x200]
    

    Call generateThumbnails() on the media entity post-upload.

  3. Entity Integration Extend C2is\BigfootMediaBundle\Entity\Media or use traits:

    use C2is\BigfootMediaBundle\Traits\MediaTrait;
    
    class Product {
        use MediaTrait;
        // ...
    }
    
  4. Symfony Event Listeners Hook into bigfoot.media.pre_upload and bigfoot.media.post_upload events for custom logic.


Gotchas and Tips

Pitfalls

  1. Deprecated Bundle

    • Last release in 2014—expect compatibility issues with modern Symfony/Laravel.
    • Replace with alternatives like vich/uploader-bundle if possible.
  2. Hardcoded Paths

    • Thumbnail paths are generated as upload_dir/thumbs/{hash}.{ext}.
    • Override C2is\BigfootMediaBundle\Service\ThumbnailService for custom logic.
  3. No Laravel Support

    • Designed for Symfony2. Use a facade or adapter for Laravel:
      // Example facade (unofficial)
      class BigfootMediaFacade {
          public static function upload($file) { /* ... */ }
      }
      

Debugging Tips

  1. Check Uploads Directory Ensure upload_dir is writable (chmod 775).

  2. Event Debugging Dump events in a listener:

    $event->getMedia()->getPath(); // Debug file path
    
  3. MIME Type Validation Override C2is\BigfootMediaBundle\Validator\Constraints\MimeType if validation fails.

Extension Points

  1. Custom Storage Extend C2is\BigfootMediaBundle\Storage\FilesystemStorage for S3/Azure.

  2. Validation Rules Add constraints to MediaType:

    ->add('media', MediaType::class, [
        'constraints' => [
            new \C2is\BigfootMediaBundle\Validator\Constraints\MaxSize(['maxSize' => '10M'])
        ]
    ])
    
  3. Template Overrides Override BigfootMediaBundle::media.html.twig for custom display logic.

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.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity