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 Chat Laravel Package

zedmagdy/filament-chat

Filament v4+ chat plugin for Laravel: configurable chat sources, 1:1 and group conversations, text + file attachments via Spatie Media Library, read/unread tracking, search, and real-time updates via polling or broadcasting (Reverb/Pusher).

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Filament Integration: Seamlessly integrates with Filament v4/v5, leveraging its UI components and panel system. The plugin follows Filament’s conventions (e.g., PanelProvider, Pages), reducing friction for teams already using Filament.
  • Modular Design: Chat sources and aggregates are decoupled, enabling granular customization (e.g., per-role chat contexts like "Staff" or "Patient"). This aligns with Laravel’s service provider pattern and Filament’s plugin architecture.
  • Real-Time Capabilities: Supports both polling (default) and broadcasting (Reverb/Pusher), making it adaptable to low-latency requirements without forcing a single approach. Broadcasting requires additional setup but scales better for high-activity chats.

Integration Feasibility

  • Laravel Ecosystem Compatibility: Built for Laravel 11/12, PHP 8.3+, and Filament 4/5. Dependencies (Spatie Media Library, Livewire) are well-established, reducing integration risk.
  • Database Schema: Publishes migrations for conversations, messages, and participants, with optional table_prefix configuration. Assumes a relational database (no NoSQL support).
  • UI Customization: Publishes Blade views for templates, allowing teams to override default styling (e.g., message bubbles, modals) via Filament’s asset pipeline.

Technical Risk

  • Real-Time Complexity: Broadcasting requires additional infrastructure (Reverb/Pusher) and frontend setup (Laravel Echo). Polling is simpler but less performant for active chats.
  • Media Library Dependency: Spatie Media Library is auto-installed but may introduce conflicts if the app already uses it for other purposes (e.g., conflicting disk configurations or collection names).
  • Scaling Assumptions: Polling intervals and pagination limits (messages_per_page, conversations_per_page) may need adjustment for large-scale deployments (e.g., 10K+ messages).
  • Authorization: Relies on Filament’s built-in auth gates. Custom participant filtering (e.g., getAvailableParticipantsQuery) must be implemented carefully to avoid performance issues with broad queries.

Key Questions

  1. Use Case Alignment:
    • Is the chat primarily for internal team communication (e.g., staff-to-staff) or external (e.g., customer support)? This affects participant models, UI flows, and real-time needs.
    • Will chats be tied to specific business entities (e.g., "Chat per support ticket")? If so, how will conversations be programmatically created/linked?
  2. Real-Time Requirements:
    • Is broadcasting feasible (infrastructure, cost)? If not, can polling intervals be optimized (e.g., 2s for active chats, 30s for inactive)?
    • Are there offline/read receipts requirements? The package tracks read status but may need extension for delivery receipts.
  3. Attachment Handling:
    • What file types/sizes are expected? The default config limits attachments to 10MB and specific MIME types. Customize via config/filament-chat.php.
    • Is there a need for preview thumbnails (e.g., for images/PDFs)? The package uses Spatie’s default upload handling.
  4. Performance:
    • How many concurrent users/chats are expected? Test with conversations_per_page and messages_per_page tuned for your dataset size.
    • Are there plans for search/filtering across chats? The package supports search but may need indexing (e.g., Laravel Scout) for large volumes.
  5. Customization Depth:
    • Will the UI need heavy customization (e.g., dark mode, branding)? The published views allow overrides, but complex changes may require forking.
    • Are there non-standard message types (e.g., rich media, reactions)? Extend the Message model or use custom fields.
  6. Migration Path:
    • Does the app already use a chat system? Assess data migration effort for conversations/messages (e.g., mapping to the chat_* tables).
    • Are there existing Filament panels/pages that might conflict with the chat plugin’s routes?

Integration Approach

Stack Fit

  • Laravel/Filament: Native fit for teams using Filament v4/v5. The package extends Filament’s PanelProvider and Page classes, requiring minimal boilerplate beyond the provided Artisan commands.
  • Real-Time: Broadcasting leverages Laravel’s Echo/Reverb integration. Polling is zero-config but less efficient. Choose based on:
    • Broadcasting: Use for high-activity chats (e.g., customer support) with Reverb/Pusher configured.
    • Polling: Use for internal tools or low-traffic chats (simpler, no WebSocket overhead).
  • Media Handling: Spatie Media Library is auto-installed but may conflict with existing setups. Audit config/filament-chat.php for disk/collection overlaps.

Migration Path

  1. Prerequisites:
    • Upgrade Laravel to 11/12 and Filament to 4.3.1+/5.0 if not already done.
    • Ensure PHP 8.3+ and Composer dependency resolution is stable.
  2. Installation:
    composer require zedmagdy/filament-chat
    php artisan vendor:publish --tag="filament-chat-migrations"
    php artisan vendor:publish --provider="Spatie\MediaLibrary\MediaLibraryServiceProvider" --tag="medialibrary-migrations"
    php artisan migrate
    
    • Risk: Media Library conflicts if already installed. Resolve by merging configs or using unique collection names.
  3. Model Integration:
    • Add HasChats trait to participant models (e.g., User, Patient).
    • Example:
      use ZEDMagdy\FilamentChat\Traits\HasChats;
      class User extends Authenticatable { use HasChats; }
      
  4. Chat Source Setup:
    • Use Artisan commands for rapid prototyping:
      php artisan make:chat-source Staff --model=User
      
    • For custom logic, extend ChatSource and override methods (e.g., getAvailableParticipantsQuery).
  5. Panel Registration:
    • Register the plugin in AdminPanelProvider:
      ->plugin(FilamentChatPlugin::make()->sources([StaffChatSource::class]))
      
  6. Real-Time Configuration:
    • Set FILAMENT_CHAT_REALTIME_MODE=broadcasting in .env if using WebSockets.
    • Configure broadcasting driver (e.g., Reverb) in config/broadcasting.php.
  7. Testing:
    • Verify UI flows: conversation creation, message sending, attachments, and real-time updates.
    • Test edge cases: group chats, participant limits, and file uploads.

Compatibility

  • Filament Versions: Tested with v4.3.1+ and v5.0. Downgrade risks if using newer Filament features.
  • Laravel Features: Uses Laravel 11/12 features (e.g., model binding, Livewire). Older versions may need polyfills.
  • Database: MySQL/PostgreSQL assumed. SQLite may need adjustments for foreign key constraints.
  • Frontend: Requires Filament’s asset pipeline for CSS/JS. Custom themes must override published views.

Sequencing

  1. Core Setup: Install package, publish migrations, and integrate models.
  2. Chat Sources: Define sources (e.g., "Support", "Internal") and register them.
  3. UI Customization: Publish and override views for branding.
  4. Real-Time: Configure broadcasting last (requires Echo setup).
  5. Extensions: Add custom logic (e.g., message events, participant filters) post-core functionality.

Operational Impact

Maintenance

  • Dependencies:
    • Monitor Spatie Media Library and Filament updates for breaking changes.
    • Pin package versions in composer.json if stability is critical:
      "zedmagdy/filament-chat": "^1.0"
      
  • Migrations: Future schema changes may require manual migration scripts if the package evolves.
  • Logs/Monitoring:
    • Track MessageSent and MessagesRead events for debugging.
    • Monitor Spatie Media Library storage usage (e.g., chat-attachments collection).

Support

  • Troubleshooting:
    • Common issues: WebSocket disconnections (broadcasting), file upload failures (Media Library), or permission errors (participant queries).
    • Debug real-time with:
      php artisan queue:work --sleep=3 --tries=1
      
    • Check Filament logs for Livewire/Blade rendering errors.
  • User Training:
    • Document chat source-specific behaviors (e.g., "Staff Chat" vs. "Patient Messages").
    • Highlight UI patterns (e.g., "+" button for new conversations, read/unread indicators).

Scaling

  • Performance Bottlenecks:
    • Database: Large conversations may hit messages_per_page limits. Optimize with:
      • Indexes on conversations.source, messages.conversation_id, participants.conversation_id.
      • Archive old messages or use Laravel’s softDeletes.
    • Real-Time: Broadcasting scales with WebSocket provider
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.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony