guanguans/soar-php
guanguans/soar-php is a PHP wrapper for Xiaomi's SOAR SQL optimizer and rewriter. It provides a simple, Laravel-friendly API to analyze, score, rewrite, and optimize SQL queries, with configurable options and support for multiple SQL dialects.
Architecture fit: Best suited to offline SQL analysis, developer tooling, CI quality gates, and admin diagnostics, not to synchronous production request handling. It can support Laravel applications as an internal “SQL lint/advisor” capability, but it should not become a runtime dependency on the query path. The package wraps an external SQL optimizer/rewriter rather than providing a pure-PHP parser, so architecture must account for a native binary, process execution, and environment parity.
Integration feasibility: Composer install and Laravel service-provider/facade usage are likely straightforward, but real feasibility depends on the host being able to execute the Soar binary via exec/proc_open. Typical Laravel deployment targets can support it, but shared hosting, restrictive containers, and hardened production environments may not. A proof of concept should validate PHP/Laravel version support, OS/architecture compatibility, binary installation, and output stability before adoption.
Technical risk: Moderate to high for production use. Key risks include low adoption signal (196 stars), incomplete repository provenance in this assessment, dependency on an external binary that must be version-pinned and patched, shell-execution and permission concerns, sensitive SQL text leaving the application boundary, MySQL-centric behavior, timeout/process failures, and output-format drift across binary versions. Automatic SQL rewriting in production should be treated as unsafe without human review and regression testing. Package MIT licensing does not automatically answer questions about the upstream binary’s license, distribution, or support model.
Key questions:
Stack fit: Fits Laravel as a developer/ops aid: an Artisan command, CI job, queued analysis job, or internal admin panel that submits SQL for recommendations. It does not fit as a middleware, query-builder replacement, or per-request production optimizer. The internal boundary should be a small service class that accepts SQL, calls the package, normalizes results, and returns advisory findings.
Migration path: Start with a sandbox proof of concept outside the request path. Install the package and required binary in a disposable environment, analyze a curated set of slow-query fixtures, compare recommendations against known indexes and execution plans, then wrap it behind an internal Artisan command or CI script. No database schema migration is required. If successful, extend to a queued job for on-demand analysis by engineers, not to automatic production query rewriting.
Compatibility: Verify PHP version, Laravel version, OS/CPU architecture, binary version, and target database dialect. Pin both the Composer package and the Soar binary, and test in the same container image used by CI and production-adjacent tooling. Avoid relying on unpinned latest binary downloads. Confirm behavior across MySQL versions and SQL features actually used by the application.
Sequencing:
EXPLAIN and DBA review.Maintenance: Requires ownership of both the PHP wrapper and the external binary. Expect periodic binary upgrades, OS/container compatibility checks, and output regression tests. The low community adoption means the team should assume more self-support than with a mainstream Laravel package. Repository/provenance gaps should be closed before relying on it.
Support: Provide a runbook for binary-not-found, permission-denied, timeout, unsupported-SQL, and malformed-output cases. Engineers need guidance that recommendations are advisory, not authoritative. DBA review remains necessary for index and rewrite decisions. Logging must avoid storing full sensitive SQL unless explicitly approved.
Scaling: Scales adequately for low-volume developer and CI usage. It is less suitable for high-QPS or batch-heavy production analysis because each call may spawn a subprocess and consume CPU/memory. Use queue workers, concurrency limits, input size caps, and timeouts. Cache or persist analysis results where repeated checks are common.
Failure modes: Missing or wrong binary version; process execution disabled; timeout or binary crash; unsupported SQL syntax; inconsistent recommendations after upgrades; sensitive SQL exposure in logs or process lists; container image drift between CI and runtime. Failures should degrade to “analysis unavailable” rather than block application requests.
Ramp-up: Low for a developer using an Artisan command; moderate for platform/ops ownership because of binary packaging, security review, and environment parity. A small pilot with DBA/platform involvement is appropriate. Adoption recommendation: conditional pilot for advisory SQL analysis and CI checks, not a core production dependency.
How can I help you explore Laravel packages today?