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

derafu/query

Expressive path-based query builder for PHP from Derafu. Build queries using readable, JSONPath-like paths for nested data structures and collections. Lightweight package with full documentation at derafu.dev/docs/data/query.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. Buy: Justifies adopting a path-based query builder to avoid reinventing custom solutions for complex nested data filtering, reducing development time and technical debt. Ideal for teams needing GraphQL-like expressiveness without the overhead of a full GraphQL server.
  • Roadmap Alignment: Enables scalable features like:
    • Dynamic API filtering (e.g., users.where('address.city', 'eq', 'Berlin')) for admin panels or public APIs.
    • Headless CMS/content APIs with flexible content queries (e.g., posts.with('author.profile')).
    • Legacy system modernization by replacing verbose SQL or hardcoded Eloquent queries with declarative path syntax.
  • Use Cases:
    • Admin dashboards requiring ad-hoc filtering (e.g., "Show orders where status = shipped AND customer.tier = premium").
    • Content APIs needing nested data traversal (e.g., articles.with('author.bio', 'tags.name')).
    • Reporting tools where SQL queries are cumbersome or underperforming.
  • Tech Stack Synergy: Complements Laravel’s Eloquent but extends it with path-based queries (e.g., query->where('user.profile.bio', 'contains', 'PHP')), bridging the gap between ORM and raw SQL while maintaining security (SQL injection protection).

When to Consider This Package

Adopt If:

  • Your application requires complex, nested data filtering (e.g., traversing relationships like user.address.city or posts.comments[*].author).
  • You’re building a Laravel API with dynamic query parameters (e.g., frontend filters) and want to avoid SQL injection risks.
  • You need GraphQL-like expressiveness for queries but lack the resources for a full GraphQL server (e.g., Lighthouse).
  • Your team prefers declarative query syntax over raw SQL or Eloquent’s fluent builder for readability and maintainability.
  • You’re using PHP 8.5+ and can tolerate early-stage tooling (MIT license, low adoption but active development).
  • You’re working with hierarchical or graph-like data (e.g., CMS content, organizational charts) where traditional joins are inefficient.

Look Elsewhere If:

  • Your queries are simple CRUD operations: Laravel Eloquent or Query Builder suffice without added complexity.
  • You require production-grade stability: The package has no dependents and minimal adoption (3 stars, untested in real-world apps).
  • You need GraphQL resolvers or subscriptions: Use a dedicated GraphQL library (e.g., Lighthouse, GraphQL PHP).
  • Your team lacks PHP 8.5+ or prefers TypeScript/JavaScript for query building (e.g., Prisma, Hasura).
  • You need real-time query validation: The package lacks built-in schema validation (unlike GraphQL).
  • Your database queries are write-heavy (e.g., bulk inserts/updates), where path-based builders may not offer advantages.

How to Pitch It (Stakeholders)

For Executives:

"This package lets us build flexible, secure data queries without writing raw SQL or overhauling our API. For example, instead of hardcoding filters like WHERE status = 'active' AND user_id IN (...), we can dynamically traverse nested data (e.g., user.address.city) with a clean, declarative syntax. This reduces backend development time by 30–50% for complex filtering—critical for our [Admin Panel/Roadmap Feature]. The MIT license and Laravel integration make it low-risk, and we can start with a pilot in [Module X]. It’s a lightweight alternative to GraphQL for teams that need expressiveness without the overhead."

For Engineering:

*"Derafu/Query offers a path-based query builder for PHP/Laravel that combines the best of Eloquent and GraphQL. Key benefits:

  • Expressiveness: Query posts.where('author.name', 'eq', 'John') instead of chaining ->whereHas()->orWhere().
  • Safety: Built-in path validation reduces SQL injection risks compared to raw SQL.
  • Laravel-Friendly: Works with Eloquent models and integrates with Doctrine DBAL (though Eloquent support may require custom adapters).
  • Early Adopter Perk: Low competition means we can shape its evolution (MIT license) and avoid vendor lock-in.

Tradeoffs:

  • Immaturity: No production dependents; we’d need to test thoroughly in staging.
  • Learning Curve: Syntax differs from Eloquent (e.g., query->where('path.to.field', 'operator', 'value')).
  • Performance Unknowns: Path queries could generate complex SQL; benchmarking required.

Proposal: Use it for [Feature Y] where dynamic filtering is painful. If successful, we can expand it to replace ad-hoc SQL in [Module Z]. Start with a pilot in non-critical endpoints to validate performance and syntax ergonomics."*

For Design/UX Teams:

*"This package enables more intuitive data filtering in our admin tools and APIs. For example:

  • Admin Panels: Filter orders by customer.tier or shipping.address.city without writing SQL.
  • Public APIs: Let frontend teams query nested data (e.g., articles?author.bio=contains:PHP) without backend changes.
  • Consistency: Standardizes how we traverse nested data across the app, reducing bugs from inconsistent queries.

It’s like GraphQL for Laravel but simpler—no schema files or resolvers, just direct path queries."*

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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
andydefer/laravel-cluster
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
christhompsontldr/laravel-inky