jasny/persist-sql-query
A lightweight PHP package for persisting SQL queries, offering a simple way to store reusable query definitions and execute them later with bound parameters. Useful for keeping complex SQL organized, reducing duplication, and maintaining cleaner database-driven applications.
Architecture fit: Low for a typical Laravel application core. Laravel already provides Eloquent, the Query Builder, and PDO-backed connections; this package is a framework-agnostic MySQL query builder/parser, not a Laravel-native persistence layer. Its best fit is tactical: SQL inspection, auditing, query rewriting, migration tooling, reporting filters, or internal admin utilities where raw SQL must be parsed or composed. It should not become the primary data-access abstraction in a Laravel domain.
Integration feasibility: Technically installable via Composer if PHP constraints permit, but integration requires an adapter layer. There is no Laravel service provider, facade, configuration contract, or Eloquent bridge. A TPM should assume custom glue code, tests, and ownership. The advertised “best and most complete” claim is unverified marketing; with 33 stars and a last release in October 2020, the package has limited community validation.
Technical risk: High. The package appears effectively unmaintained, the repository is unknown in this assessment, and PHP 8.x / Laravel 9–11 / MySQL 8 compatibility is not established. Risks include parser gaps for modern MySQL syntax, unsafe SQL string handling if identifiers or parameters are concatenated, dialect lock-in, and abandonment. Security review and dependency audit are mandatory before any production use.
Key questions:
DB::connection() without bypassing Laravel’s configuration?TPM recommendation: Do not adopt as a strategic Laravel dependency. Consider only for a narrow, isolated use case after a time-boxed proof of concept and security review.
Stack fit: Poor as a primary Laravel data layer; moderate as an internal utility. Keep it behind a project-owned interface such as SqlQueryInspector or SqlRewriteService so domain code does not depend directly on the package. Prefer Laravel’s native Query Builder/Eloquent for normal application persistence.
Migration path: Start with read-only or tooling use cases—SQL audit logs, query classification, migration analysis, or reporting filters. Avoid using it to generate production write queries until compatibility and correctness are proven. If adopted, wrap it in an adapter, feature-flag the path, and keep a native Laravel fallback.
Compatibility: Validate against our exact PHP, Laravel, and MySQL versions in CI. Because the last release is from 2020, expect PHP 8.x deprecations or incompatibilities; Composer platform constraints may require a fork. Test MySQL dialect behavior against production-like schemas, including CTEs, unions, subqueries, and JSON functions.
Sequencing:
Maintenance: High relative to value. The package has low activity and no obvious vendor support; our team would own upgrades, PHP compatibility patches, and parser bug fixes. Assign a clear maintainer and budget for fork maintenance if the PoC succeeds.
Support: Community-only, with limited stars and unclear repository governance. Incident response depends on internal expertise. Document supported SQL patterns and escalation paths before production use.
Scaling: Parsing is application-level and stateless, so it can scale horizontally with PHP workers, but parsing complex SQL adds CPU and latency. Cache parsed results where safe, cap SQL size, and avoid parsing on every request in hot paths.
Failure modes: Parser exceptions on valid MySQL 8 SQL; silent semantic changes after rewrite; incorrect parameter or identifier escaping; incompatibility after PHP/Laravel upgrades; abandonment or missing security patches. Any write-path use should fail closed, not silently fall back to unsafe SQL.
Ramp-up: Low for developers comfortable with SQL and Laravel’s Query Builder; moderate for parser internals, dialect edge cases, and safe query rewriting. Expect onboarding time for adapter conventions, supported SQL patterns, and test fixtures.
How can I help you explore Laravel packages today?