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

Filament Attachment Library Laravel Package

van-ons/filament-attachment-library

Filament Attachment Library adds a simple attachments manager to your Filament panel: upload files, browse and select existing attachments, and store them in a central library. Includes installer command, migrations/assets, and Tailwind-ready templates.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Filament Integration: The package is purpose-built for Filament 3.x/4.x/5.x, leveraging its form and resource system to provide a seamless attachment management experience. It aligns well with Filament’s modular plugin architecture, allowing for clean integration without polluting core application logic.
  • Eloquent-Centric: Built on top of Laravel Attachment Library, it extends Eloquent models via traits (HasAttachments), making it ideal for applications heavily reliant on database-backed file relationships (e.g., CMS, e-commerce, or SaaS platforms).
  • Glide Integration: Uses Glide for image processing, enabling dynamic resizing/optimization without manual intervention. This is a strong fit for media-heavy applications (e.g., galleries, avatars, or product images).
  • Disk Agnostic: Supports custom storage disks (S3, local, etc.), but defaults to public. This flexibility is critical for scalability and cloud-native deployments.

Integration Feasibility

  • Low Friction for Filament Users: Requires minimal setup beyond Composer installation and a single filament-attachment-library:install command. The plugin system abstracts away complex file handling.
  • Model-Level Granularity: Attachments can be tied to:
    • Specific columns (e.g., featured_image).
    • Relationships (e.g., gallery via HasAttachments trait). This reduces schema changes and allows for incremental adoption.
  • Blade Component Support: Frontend display is handled via <x-laravel-attachment-library-image />, ensuring consistency across views.

Technical Risk

  • Filament Version Lock: Hard dependency on Filament 3.2+ and Laravel 11. Downgrading or migrating to older versions may require forks or custom patches.
  • TailwindCSS Dependency: Custom theme setup is mandatory for styling. Projects not using Tailwind (or with custom CSS frameworks) may face integration hurdles.
  • Glide Configuration: Requires glide.php setup for image processing. Misconfiguration could break image rendering or introduce performance overhead.
  • Storage Disk Isolation: The package recommends a dedicated disk to avoid conflicts. Shared disks (e.g., public with other assets) risk file collisions or permission issues.
  • Limited Documentation for Edge Cases: While the README is thorough, complex scenarios (e.g., custom validation, bulk operations) may lack examples.

Key Questions

  1. Storage Strategy:
    • Is a dedicated disk feasible, or will we need to override the default (ATTACHMENTS_DISK)?
    • How will we handle file retention policies (e.g., soft deletes, lifecycle policies)?
  2. Performance:
    • Will Glide processing impact response times for high-traffic resources?
    • Are there plans to implement lazy loading for attachment previews?
  3. Security:
    • How will we restrict attachment uploads by file type, size, or user roles?
    • Is there built-in support for virus scanning or DDoS protection for upload endpoints?
  4. Scalability:
    • How does the package handle large-scale attachments (e.g., 10K+ files per model)?
    • Are there plans for database optimization (e.g., indexing attachment metadata)?
  5. Customization:
    • Can we extend the AttachmentField to support custom metadata (e.g., alt text, captions)?
    • Is there a way to override the default UI (e.g., drag-and-drop, bulk actions)?
  6. Migration Path:
    • How will we handle existing file storage (e.g., migrating from S3 to local disk)?
    • Are there tools to backfill attachments into the new system?

Integration Approach

Stack Fit

  • Primary Use Case: Ideal for Filament-powered admin panels where users need to manage file attachments (e.g., CMS content, user profiles, product catalogs).
  • Laravel Ecosystem Synergy:
    • Works seamlessly with Eloquent, Filament Forms/Resources, and Laravel Filesystem.
    • Complements packages like Spatie Media Library or Intervention Image for hybrid workflows.
  • Frontend Compatibility:
    • TailwindCSS-based UI ensures consistency with modern Filament themes.
    • Blade components enable easy integration into existing views.

Migration Path

  1. Assessment Phase:
    • Audit current file storage (e.g., direct uploads to S3, local directories, or third-party services).
    • Identify models requiring attachment support (prioritize high-impact resources first).
  2. Pilot Implementation:
    • Install the package in a staging environment:
      composer require van-ons/filament-attachment-library:^2.0
      php artisan filament-attachment-library:install
      
    • Set up a dedicated disk (e.g., attachments) in config/filesystems.php.
    • Configure glide.php for image processing.
  3. Incremental Rollout:
    • Phase 1: Migrate simple attachments (e.g., featured_image columns) to the new system.
    • Phase 2: Replace custom upload logic with AttachmentField in Filament forms.
    • Phase 3: Adopt HasAttachments trait for relationship-based attachments (e.g., galleries).
  4. Data Migration:
    • Use Laravel’s migration tools or custom scripts to backfill existing files into the new system.
    • Example:
      // Custom script to move files from old S3 bucket to new disk
      $oldFiles = Storage::disk('s3-old')->files('path/to/files');
      foreach ($oldFiles as $file) {
          Storage::disk('attachments')->put($file, Storage::disk('s3-old')->get($file));
      }
      
  5. Deprecation:
    • Phase out legacy upload endpoints or middleware once all critical paths use the new library.

Compatibility

  • Filament Versions: Tested with 3.2+, 4.x, and 5.x. Ensure your project’s Filament version is listed in compatibility.md.
  • PHP/Laravel: Requires PHP 8.2 and Laravel 11. Downgrading may require vendor patches.
  • Storage Backends: Supports local, S3, FTP, etc., but requires proper disk configuration.
  • Glide: Mandatory for image processing. Ensure spatie/laravel-medialibrary or spatie/glide-laravel is installed if not already.

Sequencing

  1. Prerequisites:
    • Upgrade Laravel/Filament to supported versions.
    • Set up a dedicated storage disk.
    • Configure glide.php and attachment-library.php.
  2. Core Setup:
    • Install the package and run migrations.
    • Create a custom Filament theme for Tailwind support.
  3. Model Integration:
    • Add HasAttachments trait to relevant models.
    • Define custom relationships (e.g., gallery()).
  4. Form Integration:
    • Replace custom upload fields with AttachmentField.
    • Test uploads, previews, and deletions.
  5. Frontend Integration:
    • Replace hardcoded image paths with <x-laravel-attachment-library-image />.
  6. Validation & Security:
    • Implement file type/size restrictions.
    • Test edge cases (e.g., concurrent uploads, large files).

Operational Impact

Maintenance

  • Package Updates:
    • Monitor GitHub releases for breaking changes (e.g., Filament major version bumps).
    • Test updates in staging before production deployment.
  • Dependency Management:
    • Ensure spatie/glide-laravel and van-ons/laravel-attachment-library are up-to-date.
    • Watch for security patches in underlying libraries (e.g., Laravel Filesystem).
  • Customization Overhead:
    • Extending the package (e.g., new field types) may require forking or contributing back to the repo.

Support

  • Troubleshooting:
    • Common issues include:
      • Disk misconfigurations (e.g., permissions, paths).
      • Glide processing failures (e.g., missing fonts, memory limits).
      • Tailwind styling conflicts (e.g., custom theme overrides).
    • Debugging tools:
      • php artisan storage:link for local disk issues.
      • storage:disk commands to verify disk connectivity.
      • Tailwind’s content config to ensure blade files are scanned.
  • Community Resources:
    • GitHub issues and discussions are active but not overwhelming (9 stars, low dependents).
    • Van Ons provides MIT-licensed support, but enterprise SLAs may require custom contracts.

Scaling

  • Performance:
    • Database: Attachment
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.
cocosmos/filament-sticky-save-bar
patrickbussmann/oauth2-apple
3brs/enterprise-security-bundle
anousss007/vigilance
supportpal/eloquent-model
ardenexal/fhir-models
laravel-at/laravel-image-sanitize
romalytar/yammi-audit-log-laravel
ardenexal/fhir-validation
arshaviras/weather-widget
laravel-chronicle/core
sunchayn/nimbus
daikazu/eloquent-salesforce-objects
unseen-codes/chat
romalytar/yammi-jobs-monitoring-laravel
kisame76/filament-db-table-state
nqxcode/laravel-lucene-search
dpfx/laravel-livewire-wizards
workos/workos-php-laravel
sofa/laravel-global-scope