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

Query Filter Bundle Laravel Package

braune-digital/query-filter-bundle

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

  • Symfony-Centric Design: The bundle is tightly coupled with Symfony’s ecosystem (Doctrine ORM, Symfony components), making it a natural fit for existing Symfony applications but non-trivial for Laravel/PHP monoliths or non-Symfony frameworks.
  • Query Filtering Paradigm: Leverages SQL query optimization in frontend contexts (e.g., API responses, admin panels) via server-side filtering, reducing client-side processing. Aligns with Laravel’s Eloquent query builder but requires abstraction layer to bridge Symfony’s QueryBuilder with Laravel’s Builder.
  • Separation of Concerns: Encapsulates filtering logic in a reusable bundle, but Laravel’s service container and dependency injection (DI) differ from Symfony’s. Potential for DI conflicts if not adapted.

Integration Feasibility

  • Core Functionality: Supports dynamic filtering (e.g., where, orderBy, limit) via a DSL-like syntax (e.g., filter->add('status', 'active')). Laravel’s Eloquent already handles this natively, but the bundle’s Symfony-specific abstractions (e.g., QueryBuilder, ParameterBag) would need rewrites or wrappers.
  • Frontend Integration: Designed for "frontend-like" filtering (e.g., API responses), which Laravel’s API resources or GraphQL (e.g., Lighthouse) could replicate. The bundle’s Symfony event system (e.g., filter.events) would require Laravel equivalents (e.g., listeners, events).
  • Database Agnosticism: Relies on Doctrine DBAL, but Laravel’s query builder is more flexible. Risk: Complex joins/subqueries may need manual translation.

Technical Risk

  • High Rewriting Effort: ~70% of the bundle’s logic (Symfony-specific) would need refactoring to work in Laravel:
    • Replace QueryBuilder with Laravel’s Builder.
    • Adapt ParameterBag to Laravel’s Request or Filter objects.
    • Rewrite event listeners for Laravel’s event system.
  • Performance Overhead: The bundle’s dynamic SQL generation could introduce N+1 query risks if not optimized (Laravel’s Eloquent already mitigates this with with() or load()).
  • Testing Gap: No tests or dependents indicate unproven stability. Laravel’s ecosystem expects comprehensive test coverage for third-party packages.
  • Maintenance Burden: Future Symfony updates (e.g., v6+) may break compatibility, requiring ongoing sync with Laravel’s release cycle.

Key Questions

  1. Why Not Use Laravel’s Native Tools?
    • Does the bundle offer unique features (e.g., real-time filtering, complex DSL) not covered by Eloquent scopes, API resources, or packages like spatie/laravel-query-builder?
  2. Frontend vs. Backend Filtering
    • Is the goal to offload filtering to the frontend (risky for sensitive data) or pre-filter server-side (redundant with Laravel’s built-ins)?
  3. Symfony Dependencies
    • Does the app use Symfony components (e.g., HttpFoundation, EventDispatcher) that could justify partial adoption?
  4. Alternatives
    • Would voku/portable-ascii (for query parsing) + Laravel’s query builder suffice?
    • Is GraphQL (Laravel Lighthouse) or API filtering (e.g., whereIn, orWhere) a better fit?

Integration Approach

Stack Fit

  • Laravel Compatibility: Low to Medium

    • Pros:
      • Query filtering is a core Laravel use case (Eloquent, API resources).
      • Symfony’s QueryBuilder patterns are familiar to Laravel devs (similar to Eloquent’s Builder).
    • Cons:
      • No native Symfony support: Requires wrapper classes or forking the bundle.
      • DI conflicts: Symfony’s Container vs. Laravel’s Service Provider model.
      • Event system: Symfony’s EventDispatcher ≠ Laravel’s Events facade.
  • Recommended Stack Pairings:

    Laravel Feature Bundle Equivalent Integration Path
    Eloquent Scopes QueryFilter DSL Replace bundle’s QueryBuilder with Builder
    API Resources Frontend filtering Use Laravel’s where clauses directly
    GraphQL (Lighthouse) Real-time filtering Implement custom directives
    Query Builder Packages Dynamic SQL generation Use spatie/laravel-query-builder

Migration Path

  1. Assessment Phase (2–4 weeks)

    • Audit existing filtering logic (e.g., API endpoints, admin panels).
    • Compare bundle features vs. Laravel’s native tools (e.g., Eloquent, API resources).
    • Decision Point: Abandon bundle if Laravel alternatives suffice.
  2. Proof of Concept (3–5 weeks)

    • Option A: Wrapper Layer
      • Create a Laravel service provider to translate bundle’s QueryFilter to Eloquent queries.
      • Example:
        // Symfony Bundle (Original)
        $filter->add('status', 'active')->apply($queryBuilder);
        
        // Laravel Wrapper
        $query = User::query();
        $filter = new LaravelQueryFilter(request());
        $filter->add('status', 'active')->apply($query); // Uses Eloquent
        
    • Option B: Feature Extraction
      • Extract only the filtering DSL from the bundle and port to Laravel.
      • Replace Symfony’s QueryBuilder calls with Laravel’s Builder.
  3. Full Integration (6–12 weeks)

    • Step 1: Replace Symfony-specific dependencies (e.g., HttpFoundation → Laravel’s Request).
    • Step 2: Adapt event listeners to Laravel’s Events facade.
    • Step 3: Test with complex queries (joins, subqueries, aggregations).
    • Step 4: Benchmark performance vs. native Laravel solutions.

Compatibility

  • Symfony 4/5/6: Bundle targets Symfony 4 (1.4.x), but Laravel’s DI container is incompatible.
  • PHP Version: Bundle requires PHP 7.2+; Laravel 9+ supports this.
  • Database: Doctrine DBAL → Laravel’s Illuminate\Database (mostly compatible, but raw SQL may need adjustments).
  • Frontend Frameworks: Bundle assumes Symfony UX or similar; Laravel’s Inertia.js/Vue/React would need custom adapters.

Sequencing

  1. Phase 1: Core Filtering

    • Implement basic where, orderBy, limit filters using Eloquent.
    • Risk: Losing bundle’s advanced features (e.g., nested filters).
  2. Phase 2: Advanced Features

    • Port Symfony event listeners to Laravel (e.g., filter.eventsEvent::listen).
    • Risk: Event system may not map 1:1 (e.g., Symfony’s KernelEvents vs. Laravel’s Illuminate\Events).
  3. Phase 3: Frontend Integration

    • Adapt bundle’s JavaScript/TS filtering to Laravel’s frontend stack (e.g., Inertia, Livewire).
    • Risk: Tight coupling with Symfony’s Webpack Encore may require rewrites.
  4. Phase 4: Testing & Optimization

    • Write Pest/Laravel tests for all filter combinations.
    • Optimize N+1 queries and query caching.

Operational Impact

Maintenance

  • Short-Term:
    • High effort: Requires ongoing sync between Symfony bundle updates and Laravel’s ecosystem.
    • Dependency bloat: Adding a Symfony bundle to Laravel violates PSR standards and increases attack surface.
  • Long-Term:
    • Forking risk: If the bundle evolves, Laravel-specific changes may diverge permanently.
    • Team expertise: Symfony devs may struggle with Laravel’s DI, while Laravel devs may find Symfony patterns unfamiliar.
  • Mitigation:
    • Isolate the bundle in a micro-service (e.g., Lumen) if partial adoption is unavoidable.
    • Document deviations from the original bundle (e.g., "LaravelQueryFilterBundle").

Support

  • Community Risk:
    • No stars/dependentsno community support.
    • Symfony-focused maintainers may ignore Laravel issues.
  • Vendor Lock-in:
    • Custom wrappers could become unsupportable if the bundle changes.
  • Alternatives:
    • Leverage Laravel’s first-party support (e.g., where clauses, API resources).
    • Use existing packages like:
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.
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
nawasara/auth-primitives
adhocrat-io/arkhe-main
make-dev/orca-harpoon
itsemon245/lamet
baks-dev/dashboard
amoifr/pickle-panther-bundle
make-dev/orca
dmstr/symfony-system-resources-bundle
dmstr/symfony-job-queue-bundle
dmstr/openapi-json-schema-bundle
dmstr/keycloak-security-bundle
dmstr/doctrine-audit-log-bundle