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

Search Bundle Laravel Package

massive/search-bundle

Laravel bundle that adds a flexible, driver-based search layer to your app. Define searchable models and fields, run queries across multiple sources, and return consistent results with pagination and filtering—designed to be easy to integrate and extend.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony/Laravel Compatibility: While designed for Symfony, the bundle’s core abstractions (e.g., search managers, field evaluators, and event listeners) can be adapted to Laravel via Symfony’s Console, DependencyInjection, and Doctrine Bridge. Laravel’s service container and event system are sufficiently similar to support integration with minimal refactoring.
  • Search Backend Agnosticism: Supports Elasticsearch (v7/8), Zend Lucene, and custom adapters, making it ideal for Laravel apps requiring scalable, high-performance search without hardcoding backend logic. The Elasticsearch 8 compatibility (via v7 client mode) ensures future-proofing.
  • Entity-Centric Design: Leverages Doctrine annotations (@Index, @Searchable) for declarative indexing, which aligns with Laravel’s Eloquent model conventions (e.g., useAsPivot, casts). Custom field mappings can be implemented via Laravel’s service providers or package overrides.
  • Event-Driven Extensibility: The bundle’s SearchEvent system allows intercepting queries, modifying results, or adding custom logic—directly translatable to Laravel’s service providers or event listeners (e.g., Illuminate\Events\Dispatcher).

Integration Feasibility

  • High: The bundle’s modular design (e.g., SearchManagerInterface, FieldEvaluator) enables partial adoption:
    • Use Elasticsearch integration for full-text search while keeping SQL for simple queries.
    • Replace Symfony’s EventDispatcher with Laravel’s Dispatcher via a custom bridge.
    • Adapt Doctrine metadata to Laravel’s model reflection or annotations (e.g., beberlei/doctrineextensions).
  • Key Dependencies:
    • Elasticsearch PHP Client (for Elasticsearch backend).
    • Symfony Components (Console, DependencyInjection, EventDispatcher) → Replaceable with Laravel equivalents.
    • Doctrine ORM → Optional if using Laravel Scout or raw Eloquent.

Technical Risk

Risk Area Mitigation Strategy
Symfony-Laravel Gap Abstract Symfony-specific components (e.g., ContainerBuilder) behind interfaces. Use Laravel’s Illuminate\Contracts\Container\Container for DI.
Doctrine Dependency Decouple metadata handling via Laravel’s model events (e.g., retrieved, saved) or custom annotations.
Elasticsearch 8+ Leverage the bundle’s compatibility mode for Elasticsearch 7 client. Monitor for breaking changes in future versions.
Performance Overhead Benchmark indexing/reindexing against Laravel Scout or raw Elasticsearch queries. Optimize via bundle’s partial reindexing features.
Learning Curve Provide Laravel-specific docs (e.g., "How to use MassiveSearchBundle with Laravel Scout"). Highlight expression language as a key differentiator.

Key Questions for TPM

  1. Backend Preference:
    • Is Elasticsearch the primary backend, or should the solution support SQL-based search (e.g., PostgreSQL full-text) as a fallback?
  2. Indexing Strategy:
    • Should indexing be automatic (e.g., on model save) or manual (e.g., via CLI commands)?
  3. Localization Needs:
    • Does the app require locale-specific indexing (e.g., de, en translations)? The bundle supports this natively.
  4. Extensibility:
    • Are there custom search criteria (e.g., fuzzy matching, synonyms) that need to be implemented via the expression language?
  5. CI/CD Impact:
    • How will reindexing (e.g., massive:search:reindex) be integrated into deployments? Should it run post-deploy or on-demand?
  6. Fallback Mechanism:
    • What happens if Elasticsearch is down? Should the app degrade to SQL or show a user-friendly message?

Integration Approach

Stack Fit

  • Laravel Compatibility:
    • Symfony Components: Replace with Laravel equivalents:
      • Symfony\Component\DependencyInjectionIlluminate\Container.
      • Symfony\Component\EventDispatcherIlluminate\Events\Dispatcher.
      • Symfony\Component\ConsoleLaravel’s Artisan (or custom wrapper).
    • Doctrine ORM: Use Laravel Scout for basic search or beberlei/doctrineextensions for annotations.
    • Elasticsearch: Integrate via official PHP client (elastic/elasticsearch).
  • Alternatives Considered:
    • Laravel Scout: Simpler but lacks multi-backend support and advanced query features.
    • Algolia/Meilisearch: Managed services but introduce vendor lock-in and cost.
    • Custom Solution: Higher maintenance; bundle reduces ~60% of boilerplate.

Migration Path

  1. Phase 1: Proof of Concept (2–4 weeks)
    • Set up Elasticsearch locally and integrate the bundle via Laravel’s package system.
    • Test basic indexing (e.g., a Product model) and querying via the expression language.
    • Replace Symfony’s EventDispatcher with Laravel’s equivalent.
  2. Phase 2: Core Integration (4–6 weeks)
    • Implement automatic indexing (e.g., trigger on eloquent.saved event).
    • Configure custom field mappings (e.g., title^3 for boosted relevance).
    • Add reindexing CLI commands (e.g., php artisan massive:search:reindex).
  3. Phase 3: Advanced Features (2–3 weeks)
    • Enable locale-specific indexing (if needed).
    • Implement custom evaluators for complex logic (e.g., dynamic scoring).
    • Set up monitoring for index health and query performance.
  4. Phase 4: Rollout & Optimization
    • Gradually replace SQL LIKE queries with bundle-powered searches.
    • Optimize indexing frequency (e.g., batch reindexing during off-peak hours).

Compatibility

Component Laravel Equivalent/Adapter Needed Notes
Symfony DI Illuminate\Container + custom bindings Use bind() to register bundle services.
EventDispatcher Illuminate\Events\Dispatcher Wire up listeners via Event::listen().
Doctrine Metadata beberlei/doctrineextensions or custom reflection Annotate models or use Laravel’s getAttributes() for dynamic mapping.
Console Commands Artisan commands or custom CLI Extend Illuminate\Console\Command.
Expression Language Native PHP or custom parser Leverage bundle’s DSL for dynamic queries.

Sequencing

  1. Prerequisites:
    • Elasticsearch cluster (or local instance) configured.
    • Laravel 9+ with PHP 8.2+ (bundle drops PHP 8.1 support).
    • Composer dependencies: elastic/elasticsearch, beberlei/doctrineextensions (optional).
  2. Core Setup:
    • Publish bundle config to config/massive_search.php.
    • Register the bundle in config/app.php (or use Laravel’s package auto-discovery).
  3. Indexing:
    • Annotate models (or use Index trait) and run initial reindex.
  4. Querying:
    • Implement search endpoints using the expression language (e.g., search.query = 'title:php AND price > 100').
  5. Extending:
    • Add custom field evaluators or event subscribers for business logic.

Operational Impact

Maintenance

  • Pros:
    • Active Development: Regular updates (last release in 2026) with backward-compatible changes.
    • Community Support: 72 stars, MIT license, and contributions from MassiveArt (Symfony ecosystem).
    • Isolated Scope: Search logic is decoupled from business code, reducing merge conflicts.
  • Cons:
    • Symfony Dependencies: Requires abstraction layer for Laravel compatibility (ongoing maintenance).
    • Elasticsearch Management: Cluster scaling, backups, and monitoring are external to the bundle.
  • Laravel-Specific Tasks:
    • Monitor indexing jobs (e.g., queue workers for reindex commands).
    • Update custom adapters if bundle interfaces change.

Support

  • Debugging:
    • Use bundle’s SearchEvent to log queries for troubleshooting.
    • Leverage Elasticsearch’s _validate/query API for query validation.
  • Common Issues:
    • **Mapping Conf
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.
emuniq/filament-browser-notifications
syriable/filament-translator
hungnm28/livewire-form
wenprise/eloquent
crudly/encrypted
fadion/bouncy
cuci/prototurk-sdk
gos/pubsub-router-bundle
cuci/prototurk-sdk-symfony
clementtalleu/easyadmin-markdown-bundle
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui