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: Designed as a Filament plugin, this package leverages Filament’s ecosystem (Forms, Resources, Panels) to provide a seamless admin UI for file attachments. It aligns well with Filament’s modular architecture, allowing for easy integration into existing Filament panels.
  • Eloquent Model Support: Uses Laravel’s Eloquent ORM and morph-to-many relationships to associate files with models, making it ideal for applications where files are tied to database records (e.g., CMS, e-commerce, or SaaS platforms).
  • Storage Abstraction: Built on Laravel’s Filesystem (via Storage facade), supporting disks like local, s3, or custom disks. This ensures flexibility in deployment (e.g., cloud storage for scalability).
  • Glide Integration: Uses Glide for image processing (resizing, format conversion), which is a plus for applications requiring dynamic image handling without heavy server-side processing.

Integration Feasibility

  • Low Coupling: The package is self-contained and doesn’t impose strict dependencies beyond Filament and Laravel core. It can be adopted incrementally (e.g., start with a single resource).
  • Database Schema: Requires migrations for the attachments table and a pivot table for model-attachment relationships. This is standard for Laravel and won’t disrupt existing schemas if scoped properly.
  • Frontend Dependencies: Relies on TailwindCSS for styling and Alpine.js for interactivity. Projects already using these will have minimal friction; others may need to adopt them.
  • Configuration Overrides: Supports customization via .env (e.g., ATTACHMENTS_DISK), glide.php, and attachment-library.php, reducing hardcoding.

Technical Risk

  • Filament Version Lock: Strict version compatibility (e.g., v2 requires Filament ≥4.0 or ≥5.0). Upgrading Filament may require package updates, risking breaking changes.
  • Storage Disk Isolation: Recommends a dedicated disk for attachments to avoid conflicts. Misconfiguration could lead to file corruption or permission issues.
  • Glide Dependency: Requires Glide for image processing, adding a minor dependency. Projects not using Glide may need to configure it or handle images differently.
  • TailwindCSS Requirement: Custom themes must include the package’s Blade templates in tailwind.config.js. Omitting this could break UI rendering.
  • JavaScript Build Step: Custom Alpine components require rebuilding assets (npm run build). CI/CD pipelines must account for this.

Key Questions

  1. Filament Version Alignment:
    • Is the project’s Filament version compatible with this package (v2 requires ≥4.0 or ≥5.0)?
    • What’s the upgrade path if Filament needs to be updated?
  2. Storage Strategy:
    • Is a dedicated disk feasible, or will attachments share a disk with other files?
    • Are there performance implications for the chosen disk (e.g., S3 latency)?
  3. Image Processing Needs:
    • Does the project already use Glide? If not, is the overhead acceptable?
  4. UI/UX Customization:
    • Are the default Tailwind styles sufficient, or will extensive theming be required?
  5. Scalability:
    • How will attachment volumes scale (e.g., 10K+ files)? Are there limits to the morph-to-many relationship?
  6. Security:
    • How will file uploads be validated (e.g., MIME types, size limits)?
    • Are there risks of path traversal or injection if basePath uses dynamic values (e.g., tenant slugs)?

Integration Approach

Stack Fit

  • Laravel Ecosystem: Perfect fit for Laravel applications using Filament for admin panels. Leverages Eloquent, Filesystem, and Glide seamlessly.
  • Filament-Specific: Designed for Filament’s Resources and Forms, enabling attachment management within CRUD interfaces. Works alongside Filament’s existing fields (e.g., RichEditor, FileUpload).
  • Frontend Agnostic: While it uses Tailwind/Alpine, the backend logic is decoupled, allowing frontend frameworks (e.g., Livewire, Inertia) to consume the attachments via API or Blade components.

Migration Path

  1. Assessment Phase:
    • Audit existing file storage (e.g., direct uploads to public/storage, S3 buckets, or custom solutions).
    • Identify models requiring attachments (e.g., Product, Post, User).
  2. Pilot Integration:
    • Start with a single resource (e.g., Product) to test the AttachmentField and HasAttachments trait.
    • Use the install command to set up migrations and assets.
  3. Incremental Rollout:
    • Gradually replace legacy file-handling logic (e.g., manual request()->file()) with the package’s fields.
    • Migrate existing files to the new disk using a data script.
  4. Frontend Adaptation:
    • Update Blade templates to use <x-laravel-attachment-library-image> for displaying attachments.
    • Ensure TailwindCSS is configured to include the package’s assets.

Compatibility

  • Laravel 11/Filament 3.2+: Officially supported. Projects using older versions may need to use v1 or fork the package.
  • Storage Backends: Works with any Laravel disk (local, S3, etc.), but performance may vary (e.g., S3 requires CORS configuration).
  • Glide: Required for image processing. Projects without Glide must install it (composer require glidephp/glide).
  • JavaScript: Alpine.js is bundled; ensure Vite/Webpack can process the package’s JS artifact.

Sequencing

  1. Backend Setup:
    • Install the package and run migrations.
    • Configure filesystems.php and .env for the attachments disk.
    • Register the plugin in PanelProvider.
  2. Model Integration:
    • Add HasAttachments trait to relevant models.
    • Define custom relationships (e.g., gallery()) if needed.
  3. Form Integration:
    • Replace or add AttachmentField to Filament forms.
    • Configure validation (e.g., mime(), multiple()).
  4. Frontend Integration:
    • Update Blade templates to display attachments.
    • Customize Tailwind styles if necessary.
  5. Testing:
    • Verify uploads, deletions, and relationships.
    • Test edge cases (e.g., large files, concurrent uploads).

Operational Impact

Maintenance

  • Package Updates: Monitor for Filament compatibility breaks. The filament:upgrade Artisan command may need to be run post-update.
  • Storage Management:
    • Regularly prune orphaned attachments (e.g., via Attachment::whereNotExists()->delete()).
    • Monitor disk space for the dedicated storage.
  • Glide Maintenance: Update Glide if new Laravel versions require it.
  • Tailwind/Alpine: Rebuild assets (npm run build) after package updates or custom JS changes.

Support

  • Debugging:
    • Use filament-attachment-library:install --force to reinstall migrations/assets if corrupted.
    • Check storage/logs/laravel.log for file upload errors (e.g., disk permissions).
  • Common Issues:
    • Permission Denied: Ensure the storage disk’s user/group has write access.
    • Missing Styles: Verify tailwind.config.js includes the package’s Blade paths.
    • Alpine Errors: Clear Vite cache (npm run dev) if JS fails to load.
  • Documentation: The package’s docs are comprehensive but assume familiarity with Filament/Laravel. Internal runbooks may be needed for onboarding.

Scaling

  • Performance:
    • Database: Morph-to-many relationships can bloat the database. Consider indexing attachmentable_id and collection columns.
    • Storage: For high-volume attachments, use S3 or similar with proper caching headers.
    • Glide: Offload image processing to a queue (e.g., glide:generate) to avoid blocking requests.
  • Concurrency:
    • File uploads may contend for disk I/O. Consider chunked uploads for large files.
    • Use Laravel’s sync queue driver for attachment processing if async is needed.
  • Horizontal Scaling:
    • Shared storage (e.g., S3) is required for multi-server deployments.
    • Avoid local disks in clustered environments.

Failure Modes

Failure Scenario Impact Mitigation
Disk full or inaccessible Uploads fail, existing files lost Set up monitoring (e.g., Laravel Horizon).
Database corruption (orphaned rows) Inconsistent attachment relationships Use soft deletes and regular database backups.
Glide misconfiguration Broken image thumbnails Test Glide routes (/glide/...) manually.
Tailwind/Alpine build failures Broken UI Ensure node_modules is intact; rebuild assets.
Concurrent uploads File conflicts or corruption Use unique filenames (e.g.,
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