PHPackages                             masnathan/sql-query-formatter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. masnathan/sql-query-formatter

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

masnathan/sql-query-formatter
=============================

A very lightweight PHP class that reformats unreadable and computer-generated SQL query statements to human-friendly, readable text.

v1.2.1(10y ago)01.8k1MITPHPPHP &gt;=5.3

Since Jun 27Pushed 10y ago1 watchersCompare

[ Source](https://github.com/MASNathan/sql-query-formatter)[ Packagist](https://packagist.org/packages/masnathan/sql-query-formatter)[ Docs](http://nilportugues.com)[ RSS](/packages/masnathan-sql-query-formatter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (6)Used By (1)

SQL Query Formatter
===================

[](#sql-query-formatter)

[![Build Status](https://camo.githubusercontent.com/1057b160e64c5cc2299812fc3af820f451cafced4e2ede67b6fbbfa31d0443f2/68747470733a2f2f7472617669732d63692e6f72672f6e696c706f727475677565732f73716c2d71756572792d666f726d61747465722e737667)](https://travis-ci.org/nilportugues/sql-query-formatter) [![Coverage Status](https://camo.githubusercontent.com/58aabb341a485c6e5336e5ee9ffedaace4922857f1a6f44e64d71342d8181f3a/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6e696c706f727475677565732f73716c2d71756572792d666f726d61747465722e737667)](https://coveralls.io/r/nilportugues/sql-query-formatter?branch=master) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/26a3cf29629c2c8ed08e4eb1bd9a089de8df9d3ab0756b5998e7f7cb03e4dbe4/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6e696c706f727475677565732f73716c2d71756572792d666f726d61747465722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/nilportugues/sql-query-formatter/?branch=master) [![SensioLabsInsight](https://camo.githubusercontent.com/f801cec15c4f307e7d0c5687e21254f1c18558663a4def2aa5b9f0d9cf1f7139/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f61353761613866332d626265312d343361352d393431652d3638396438343335616232302f6d696e692e706e67)](https://insight.sensiolabs.com/projects/a57aa8f3-bbe1-43a5-941e-689d8435ab20) [![Latest Stable Version](https://camo.githubusercontent.com/bf5360401013e3a135691ba390e37c55c423567ebe1b7ccda82b19282ad16033/68747470733a2f2f706f7365722e707567782e6f72672f6e696c706f727475677565732f73716c2d71756572792d666f726d61747465722f762f737461626c65)](https://packagist.org/packages/nilportugues/sql-query-formatter) [![Total Downloads](https://camo.githubusercontent.com/830b913345e13e808637010b15abfd6f5e17f9761e940b41b6dd8adad0171f2a/68747470733a2f2f706f7365722e707567782e6f72672f6e696c706f727475677565732f73716c2d71756572792d666f726d61747465722f646f776e6c6f616473)](https://packagist.org/packages/nilportugues/sql-query-formatter) [![License](https://camo.githubusercontent.com/8d00d52f58e6b3f8ba4d9f7bee44113fc44599bd546b84b827328385a389cec0/68747470733a2f2f706f7365722e707567782e6f72672f6e696c706f727475677565732f73716c2d71756572792d666f726d61747465722f6c6963656e7365)](https://packagist.org/packages/nilportugues/sql-query-formatter)

A very lightweight PHP class that re-formats unreadable or computer-generated SQL query statements to human-friendly readable text.

- [1.Installation](#block1)
- [2. Features](#block2)
- [3. Usage](#block3)
- [4. Code Quality](#block5)
- [5. Author](#block6)
- [6. Special Thanks](#block6)
- [7. License](#block7)

1.Installation
--------------

[](#1installation)

The recommended way to install the SQL Query Formatter is through [Composer](http://getcomposer.org). Run the following command to install it:

```
php composer.phar require nilportugues/sql-query-formatter
```

2. Features
-----------

[](#2-features)

**Human readable SQL formatting**

- Human readable plain text. No colours, no highlighting. Plain text is good enough in most cases.

**Data Binding Awareness**

- SQL Query Formatter takes data binding seriously.
- Placeholder syntax such as `:variable` or `?` is taken into account and is preserved when formatting.

3. Usage
--------

[](#3-usage)

Sample code:

```
