Weave 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

Sql Parser Laravel Package

phpmyadmin/sql-parser

phpmyadmin/sql-parser is a validating SQL lexer and parser for PHP with a focus on MySQL. It lets you parse, lint, tokenize, format, and analyze SQL queries, and ships with CLI utilities and a Composer-installable library for query discovery and formatting.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • SQL Query Analysis & Validation: Enables parsing, validating, and analyzing SQL queries (MySQL dialect) programmatically, supporting features like syntax highlighting, query optimization helpers, or security scanning.
  • Database Tooling: Accelerates development of admin panels, query builders, or IDE plugins (e.g., auto-complete, query linting, statement formatting).
  • Build vs. Buy: Avoids reinventing SQL parsing/formatting logic, reducing dev time and technical debt. Release 6.0.1 shows sustained maintenance (PHP 8.5/8.6 compatibility, PHPUnit 13 support), which lowers the long-term ownership risk of this dependency.
  • Formatter Reliability Now De-risked: 6.0.1 fixes formatting/round-trip defects that directly affect user-visible output — INSERT statements now respect the context's quote style, and JSON path operators (->, ->>) format without spacing errors. If a "pretty-print SQL" or "copy generated query" feature is on the roadmap, this release removes known polish bugs rather than adding new surface area.
  • Robustness for Untrusted Input: Null-safety fixes (getAliases() offset handling, "read property 'keyword' on null", index validation with sort order) reduce crash risk when parsing malformed or partial user-supplied SQL — relevant to any editor or validator exposed to end users.
  • Roadmap Priorities:
    • Phase 1: Integrate for validation + formatting in an internal or user-facing query editor; pin to 6.0.1 for the formatter and null-safety fixes.
    • Phase 2: Extend to query rewriting / normalization (e.g., performance tuning, query fingerprinting).
    • Phase 3: Embed in a broader SQL analytics platform (query performance insights, policy enforcement).
  • Use Cases:
    • Security: Detect suspicious SQL patterns (stacked statements, UNION SELECT, dynamic table names) and normalize queries for fingerprinting. Treat this as one signal among several — not a sole injection defense.
    • DevOps: Automate query linting/format checks in CI pipelines.
    • User-Facing: Power a "smart" SQL editor with formatting and validation for less-technical users.

When to Consider This Package

  • Adopt if:
    • Your product relies on MySQL SQL parsing, validation, or formatting (query editors, ORMs, admin tooling, analytics).
    • You need lightweight, accurate parsing without database drivers — this is a pure PHP parser.
    • Your team lacks the appetite to build and maintain a SQL grammar from scratch.
    • You are on — or planning to move to — PHP 8.6: 6.0.1 explicitly adds support, so the dependency will not block a runtime upgrade.
    • You're building open-source or GPL-compatible tools (package is GPL-2.0).
  • Look elsewhere if:
    • You require multi-database support (PostgreSQL, SQLite, MSSQL) — this is MySQL-dialect specific.
    • You need query execution or EXPLAIN plans — pair with a DB client; the parser does not execute.
    • Your use case demands real-time parsing of very large or deeply nested queries — parsing cost scales with query complexity; benchmark before committing to keystroke-level validation.
    • You're in a closed-source/commercial product where GPL-2.0 obligations are unacceptable — consider a permissively licensed alternative or a build decision.
    • You need guaranteed semantic equivalence for rewrites (round-trip fidelity is good but not formally specified; validate generated SQL against a real MySQL instance).

How to Pitch It (Stakeholders)

For Executives: "This package gives us production-grade MySQL parsing, validation, and formatting without building a SQL grammar in-house — saving an estimated 6–12 months of engineering. The 6.0.1 release is a maintenance release: no breaking changes, but it fixes user-visible formatting bugs and adds PHP 8.6 compatibility, so adopting it now does not put us at risk during our next runtime upgrade. Upgrade cost is effectively zero — it's a patch-level bump."

For Engineering: *"phpmyadmin/sql-parser 6.0.1 is a low-risk dependency update:

  • PHP 8.6 and PHPUnit 13 support, plus PHP 8.5 deprecation fixes — safe to adopt ahead of runtime upgrades.
  • Formatter fixes for JSON path operators (->, ->>) and INSERT quote-style handling; if we generate/round-trip SQL, output now matches the source dialect more faithfully.
  • Null-safety fixes in alias handling and index validation reduce crashes on partial/malformed input — a real win for editor autocomplete and validation paths. Tradeoffs: MySQL dialect only, no execution, and it's a parser (not a linter) — we own the rules. Ready to prototype in ~2 weeks; recommend pinning 6.0.1 and adding round-trip + malformed-input tests to our suite."

For Security/Compliance: "This supports SQL normalization and query fingerprinting — useful for anomaly detection, allow-listing, and audit trails — plus flagging of high-risk patterns (stacked statements, UNION SELECT, dynamic table names). It is a defense-in-depth signal, not a substitute for parameterized queries: any detection layer built on a parser must be validated against a corpus of known-bad queries to measure false positives and false negatives before we advertise coverage."

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.
mehedimi/laravel-amp-mail
happones/laravel-vue-i18n-generator
jwerd/inertia-table
siberfx/flysystem-wasabi
hollyit/token-replace
ippanelcom/laravel-sdk
adachsoft/changelog-linter
adachsoft/collection
payerurl/telegrambot-crypto-payment-instant-payout
dskripchenko/laravel-hybrid-search
riorizkyrainey/lara-ced
mehedimi/static-vel
zharp/zharp
nonsapiens/bigquery-model-sync
lgu-bayambang-ict-office/lgu-laravel-development-standards
andydefer/laravel-support
se7enxweb/flysystem
lampwick/laravel
jeslage/statamic-emojis
micahdshackelford/rmap-laravel