A lightweight PHP class for formatting SQL statements with automatic indentation and syntax highlighting.
SqlFormatter is a lightweight PHP library that formats SQL statements to improve readability. It automatically indents and adds line breaks to SQL queries, and can also apply syntax highlighting for HTML output. It helps developers debug and analyze SQL by providing clean, structured output.
PHP developers who need to debug, log, or analyze raw SQL statements, particularly those working with auto-generated queries or complex database interactions.
Developers choose SqlFormatter for its simplicity and performance, offering essential formatting features without the bloat of larger libraries. It provides reliable query splitting and formatting options that handle edge cases better than basic regex solutions.
A lightweight php class for formatting sql statements. Handles automatic indentation and syntax highlighting.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses tokenization instead of regex, correctly splitting queries with quoted semicolons—a common failure point for simpler methods like explode().
Offers both HTML syntax highlighting and plain text formatting, making it versatile for web display, error logs, or command-line use.
A single PHP class file with no dependencies, easy to integrate into projects without adding bloat or complex setup.
Provides separate methods to compress queries by removing comments and whitespace, or just strip comments while preserving original formatting.
The README admits splitQuery fails with DELIMITER commands, CREATE PROCEDURE, and USE statements without semicolons, making it unreliable for complex database scripts.
Implemented as a static class, which can hinder testability, extensibility, and integration in modern PHP applications using dependency injection.
Focuses on standard SQL; may not properly handle database-specific syntax or newer SQL features without manual updates or extensions.