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

Multi Search Bundle Laravel Package

petkopara/multi-search-bundle

Symfony bundle that adds a Multi Search service and form type for Doctrine. Build a QueryBuilder to search across all or selected entity columns using a single term, with optional wildcard matching, and reuse it in your controllers or forms.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Pros:

    • Symfony/Doctrine Integration: Seamlessly integrates with Symfony’s Form component and Doctrine ORM, aligning with modern Laravel/Lumen’s Eloquent/Query Builder patterns (though Laravel lacks native Symfony bundles, this can be adapted via custom wrappers).
    • Flexible Search Logic: Supports wildcard, exact, prefix/suffix matching, which covers ~80% of basic search use cases (e.g., autocomplete, full-text).
    • QueryBuilder Abstraction: Returns a modified QueryBuilder (or Query in Laravel terms), enabling further chaining (e.g., pagination, sorting).
    • Form-Centric Design: Leverages Symfony’s form system, which can be mirrored in Laravel using FormRequest or custom form builders (e.g., Laravel Collective or Filament).
  • Cons:

    • Symfony-Specific: Hard dependencies on Symfony’s FormBuilder, DependencyInjection, and Kernel make direct Laravel integration non-trivial (requires abstraction layers).
    • Outdated: Last release in 2016 raises concerns about compatibility with modern PHP (8.0+) and Doctrine (3.x+). May need polyfills or forks.
    • Limited to Doctrine: Focuses solely on ORM queries; lacks support for Eloquent’s dynamic properties or non-DB search (e.g., Algolia, Elasticsearch).
    • No Laravel Ecosystem: Zero dependents or Laravel-specific adaptations suggest niche relevance.

Integration Feasibility

  • Laravel Adaptation Path:
    1. Service Wrapper: Create a Laravel service class to replicate the bundle’s searchEntity() logic using Eloquent’s QueryBuilder or raw SQL.
      class MultiSearchService {
          public function search(Builder $query, string $model, string $searchTerm, array $fields = [], string $type = 'wildcard') {
              // Translate Symfony logic to Laravel/Eloquent
          }
      }
      
    2. Form Integration: Use Laravel’s FormRequest or a package like laravel-form to mirror the MultiSearchType.
    3. Middleware/Traits: Abstract search logic into traits or middleware for reuse across controllers.
  • Key Challenges:
    • Symfony DI: Laravel’s IoC container differs; manual binding or a facade pattern may be needed.
    • QueryBuilder Differences: Laravel’s Builder vs. Doctrine’s QueryBuilder requires method mapping (e.g., where() vs. andWhere()).
    • Testing: Outdated codebase may need modern PHP unit tests (PHPUnit 9+).

Technical Risk

  • High:
    • Compatibility: PHP 8.0+ features (e.g., named arguments, union types) may break the bundle. Requires testing or forking.
    • Maintenance Burden: No active development; fixes for bugs or new features would need internal effort.
    • Performance: Wildcard searches (LIKE '%term%') are slow on large datasets. May need database-level optimizations (e.g., full-text indexes).
    • Security: SQL injection risk if not properly sanitized (though Doctrine/Laravel’s QueryBuilder mitigates this).
  • Mitigation:
    • Fork and Modernize: Update dependencies and PHP version in a private repo.
    • Hybrid Approach: Use the bundle’s logic for simple cases but offload complex searches to Elasticsearch/Algolia.
    • Benchmark: Test performance with 10K+ records to validate feasibility.

Key Questions

  1. Business Justification:
    • Does the team need exact Symfony bundle functionality, or are Laravel-native alternatives (e.g., spatie/laravel-searchable) sufficient?
    • Is the 2016 release date acceptable for production use, or is a fork/migration required?
  2. Technical Trade-offs:
    • Would a custom implementation (e.g., using Eloquent macros) be simpler than adapting this bundle?
    • Are there database-specific optimizations (e.g., PostgreSQL full-text search) that could replace this?
  3. Team Skills:
    • Does the team have experience with Symfony bundles or Doctrine QueryBuilder to handle integration quirks?
  4. Alternatives:

Integration Approach

Stack Fit

  • Laravel Compatibility:

    • Partial Fit: The bundle’s core logic (multi-column search with comparison types) is language-agnostic and can be reimplemented in Laravel. However, Symfony-specific components (e.g., FormType, DependencyInjection) require abstraction.
    • Recommended Stack:
      Symfony Component Laravel Equivalent Notes
      FormBuilder FormRequest + Request Use Illuminate\Http\Request or Laravel Collective forms.
      QueryBuilder Eloquent Builder Method signatures differ (e.g., andWhere vs. where).
      Service Container Laravel’s IoC Bind service manually or use facades.
      Doctrine ORM Eloquent Similar but not identical APIs.
  • Non-Functional Requirements:

    • Performance: Wildcard searches may need database optimizations (e.g., MATCH ... AGAINST in MySQL).
    • Scalability: For large datasets, consider Elasticsearch or database full-text indexes.
    • Extensibility: Laravel’s service container allows easy extension (e.g., adding new search types).

Migration Path

  1. Assessment Phase:
    • Audit current search implementation (e.g., manual LIKE queries, Scout, Algolia).
    • Define must-have vs. nice-to-have features (e.g., wildcard support, form integration).
  2. Proof of Concept (PoC):
    • Implement a minimal Laravel service replicating searchEntity() logic.
    • Test with a sample entity (e.g., Post with title and body fields).
    • Compare performance with existing solutions.
  3. Full Integration:
    • Option A: Fork and Adapt:
      • Update the bundle to PHP 8.0+ and Doctrine 3.x.
      • Replace Symfony dependencies with Laravel equivalents (e.g., illuminate/support).
      • Publish as a private package or open-source fork.
    • Option B: Custom Implementation:
      • Create a Laravel package with similar functionality using Eloquent macros or traits.
      • Example:
        // app/Traits/MultiSearchable.php
        trait MultiSearchable {
            public function scopeMultiSearch($query, string $searchTerm, array $fields = [], string $type = 'wildcard') {
                foreach ($fields as $field) {
                    $query->where($field, $type === 'wildcard' ? "%{$searchTerm}%" : $searchTerm);
                }
                return $query;
            }
        }
        
    • Option C: Hybrid Approach:
      • Use the bundle for Symfony microservices (if applicable) and Laravel-native solutions elsewhere.
  4. Form Integration:
    • Replace MultiSearchType with a Laravel form builder (e.g., using Laravel Collective or Filament).
    • Example:
      use Illuminate\Support\Facades\Validator;
      
      $validator = Validator::make($request->all(), [
          'search' => 'required|string',
      ]);
      $query = Post::query()->multiSearch($request->search, ['title', 'body']);
      

Compatibility

  • Doctrine vs. Eloquent:
    • Query Methods: Doctrine’s QueryBuilder uses andWhere(), orWhere(), etc., while Eloquent uses where() with method chaining.
    • Solution: Abstract differences in a service layer or use a package like doctrine/orm in Laravel (not recommended; adds complexity).
  • PHP Version:
    • Bundle requires PHP 5.5+; Laravel 9+ requires PHP 8.0+.
    • Action: Fork and update composer.json to target PHP 8.0+.
  • Symfony Dependencies:
    • symfony/form, symfony/dependency-injection: Replace with Laravel equivalents or isolate logic.

Sequencing

  1. Phase 1: Core Logic (2–3 days)
    • Implement MultiSearchService in Laravel.
    • Test with basic wildcard/equals searches.
  2. Phase 2: Form Integration (
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