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

Laravel Query Expressions Laravel Package

tpetry/laravel-query-expressions

Add powerful SQL expression support to Laravel’s query builder. Compose reusable, type-safe expressions for functions, casts, JSON ops, windows, and more, with clean syntax and cross-database compatibility—ideal for advanced filtering, sorting, and computed columns.

Deep Wiki
Context7

Product Decisions This Supports

  • Build vs. Buy: Accelerates development by eliminating the need to build custom query builders or raw SQL abstractions, reducing technical debt and maintenance overhead.
  • Feature Expansion: Enables safer, more maintainable dynamic query generation for:
    • Admin panels (filtering, sorting, pagination).
    • APIs (complex search/faceted queries).
    • Legacy system migrations (replacing raw SQL with expressive syntax).
  • Roadmap Alignment: Supports scalable query logic without coupling to Eloquent models, ideal for:
    • Multi-tenant applications (tenant-aware queries).
    • Analytics dashboards (ad-hoc aggregations).
    • Microservices (query composition across services).
  • Security: Mitigates SQL injection risks by enforcing type-safe query construction.

When to Consider This Package

Adopt if:

  • Your team frequently writes raw SQL in Laravel (e.g., DB::select(), DB::table()->toSql()) and wants to replace it with a structured, debuggable alternative.
  • You need reusable query logic (e.g., shared filters across controllers/services) without bloating Eloquent models.
  • Your queries involve complex joins, subqueries, or dynamic conditions that are hard to maintain with raw SQL or Eloquent.
  • You prioritize developer experience (e.g., IDE autocompletion, type safety) over minimalist query syntax.

Look elsewhere if:

  • Your queries are simple CRUD operations already handled well by Eloquent.
  • You’re using raw SQL for performance-critical paths (this package adds abstraction overhead).
  • Your team lacks PHP/Laravel familiarity (steep learning curve for advanced features).
  • You need database-agnostic queries (this is SQL-specific).

How to Pitch It (Stakeholders)

For Executives: "This package lets our engineers replace error-prone raw SQL with a structured, reusable query system—like building blocks for database operations. It cuts debugging time, reduces SQL injection risks, and future-proofs our admin tools/APIs. For example, a complex dashboard filter that now takes 2 devs 2 weeks could be built in days with maintainable code. The MIT license and Laravel ecosystem adoption make it a low-risk upgrade."

For Engineers: *"Imagine writing queries like this instead of raw SQL:

$users = Query::select('users.*')
    ->from('users')
    ->where(Query::expr('age > ?', [25]))
    ->join('orders', Query::expr('users.id = orders.user_id AND orders.status = ?', ['active']))
    ->get();
  • Pros: Type-safe, reusable, debuggable (works with Laravel’s query log).
  • Use Cases: Admin filters, multi-tenant queries, or any dynamic SQL.
  • Tradeoff: Slightly more verbose than raw SQL but far safer and scalable. Let’s prototype it for [high-pain query X] and measure dev time saved."*

For Security/Compliance Teams: "This package enforces parameter binding and structured query composition, eliminating most SQL injection vectors. It’s a drop-in replacement for raw SQL calls, so we can audit and standardize queries without rewriting business logic."

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.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport