PHPackages                             rob-lester-jr04/php-sql-parser - 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. rob-lester-jr04/php-sql-parser

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

rob-lester-jr04/php-sql-parser
==============================

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL - Modernized for use with composer practices and Laravel 5+

v4.4.0(5y ago)010BSD-3-ClausePHPPHP &gt;=5.3.2

Since Apr 16Pushed 4y agoCompare

[ Source](https://github.com/roblesterjr04/PHP-SQL-Parser)[ Packagist](https://packagist.org/packages/rob-lester-jr04/php-sql-parser)[ Docs](https://github.com/greenlion/PHP-SQL-Parser)[ RSS](/packages/rob-lester-jr04-php-sql-parser/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (3)Versions (11)Used By (0)

[![Build Status](https://camo.githubusercontent.com/c09c6169a21f411b2f8fbebfaa83b5f4f8300bf25b6df3c6da9bed8a3e468498/68747470733a2f2f7472617669732d63692e6f72672f677265656e6c696f6e2f5048502d53514c2d5061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/greenlion/PHP-SQL-Parser)

PHP-SQL-Parser
==============

[](#php-sql-parser)

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL

### Download

[](#download)

[GitHub Wiki](https://github.com/greenlion/PHP-SQL-Parser/wiki/Downloads)

### Full support for the MySQL dialect for the following statement types

[](#full-support-for-the-mysql-dialect-for-the-following-statement-types)

```
SELECT
INSERT
UPDATE
DELETE
REPLACE
RENAME
SHOW
SET
DROP
CREATE INDEX
CREATE TABLE
EXPLAIN
DESCRIBE

```

### Other SQL statement types

[](#other-sql-statement-types)

Other statements are returned as an array of tokens. This is not as structured as the information available about the above types. See the [ParserManual](https://github.com/greenlion/PHP-SQL-Parser/wiki/Parser-Manual) for more information.

### Other SQL dialects

[](#other-sql-dialects)

Since the MySQL SQL dialect is very close to SQL-92, this should work for most database applications that need a SQL parser. If using another database dialect, then you may want to change the reserved words - see the [ParserManual](https://github.com/greenlion/PHP-SQL-Parser/wiki/Parser-Manual). It supports UNION, subqueries and compound statements.

### External dependencies

[](#external-dependencies)

The parser is a self contained class. It has no external dependencies. The parser uses a small amount of regex.

### Focus

[](#focus)

The focus of the parser is complete and accurate support for the MySQL SQL dialect. The focus is not on optimizing for performance. It is expected that you will present syntactically valid queries.

### Manual

[](#manual)

[ParserManual](https://github.com/greenlion/PHP-SQL-Parser/wiki/Parser-Manual) - Check out the manual.

### Example Output

[](#example-output)

**Example Query**

```
SELECT STRAIGHT_JOIN a, b, c
  FROM some_table an_alias
 WHERE d > 5;
```

**Example Output (via print\_r)**

```
Array
(
    [OPTIONS] => Array
        (
            [0] => STRAIGHT_JOIN
        )

    [SELECT] => Array
        (
            [0] => Array
                (
                    [expr_type] => colref
                    [base_expr] => a
                    [sub_tree] =>
                    [alias] => `a`
                )

            [1] => Array
                (
                    [expr_type] => colref
                    [base_expr] => b
                    [sub_tree] =>
                    [alias] => `b`
                )

            [2] => Array
                (
                    [expr_type] => colref
                    [base_expr] => c
                    [sub_tree] =>
                    [alias] => `c`
                )

        )

    [FROM] => Array
        (
            [0] => Array
                (
                    [table] => some_table
                    [alias] => an_alias
                    [join_type] => JOIN
                    [ref_type] =>
                    [ref_clause] =>
                    [base_expr] =>
                    [sub_tree] =>
                )

        )

    [WHERE] => Array
        (
            [0] => Array
                (
                    [expr_type] => colref
                    [base_expr] => d
                    [sub_tree] =>
                )

            [1] => Array
                (
                    [expr_type] => operator
                    [base_expr] => >
                    [sub_tree] =>
                )

            [2] => Array
                (
                    [expr_type] => const
                    [base_expr] => 5
                    [sub_tree] =>
                )

        )

)
```

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 91% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~423 days

Recently: every ~407 days

Total

7

Last Release

1877d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/37a376a6bb4b688512897fd2afdef71c99a37529f1b3002d43d699843eb9cbc7?d=identicon)[roblesterjr04](/maintainers/roblesterjr04)

---

Top Contributors

[![witchi](https://avatars.githubusercontent.com/u/5766508?v=4)](https://github.com/witchi "witchi (2331 commits)")[![greenlion](https://avatars.githubusercontent.com/u/465334?v=4)](https://github.com/greenlion "greenlion (119 commits)")[![polevaultweb](https://avatars.githubusercontent.com/u/1770201?v=4)](https://github.com/polevaultweb "polevaultweb (20 commits)")[![donatj](https://avatars.githubusercontent.com/u/133747?v=4)](https://github.com/donatj "donatj (19 commits)")[![dbould](https://avatars.githubusercontent.com/u/5477476?v=4)](https://github.com/dbould "dbould (12 commits)")[![moufmouf](https://avatars.githubusercontent.com/u/1290952?v=4)](https://github.com/moufmouf "moufmouf (7 commits)")[![gilbitron](https://avatars.githubusercontent.com/u/203882?v=4)](https://github.com/gilbitron "gilbitron (7 commits)")[![yfix](https://avatars.githubusercontent.com/u/659419?v=4)](https://github.com/yfix "yfix (6 commits)")[![PSF1](https://avatars.githubusercontent.com/u/10193279?v=4)](https://github.com/PSF1 "PSF1 (5 commits)")[![oohook](https://avatars.githubusercontent.com/u/4328913?v=4)](https://github.com/oohook "oohook (4 commits)")[![jdorrestijn](https://avatars.githubusercontent.com/u/36915981?v=4)](https://github.com/jdorrestijn "jdorrestijn (4 commits)")[![nicoder](https://avatars.githubusercontent.com/u/365210?v=4)](https://github.com/nicoder "nicoder (3 commits)")[![shokre](https://avatars.githubusercontent.com/u/6144138?v=4)](https://github.com/shokre "shokre (2 commits)")[![Herz3h](https://avatars.githubusercontent.com/u/1900696?v=4)](https://github.com/Herz3h "Herz3h (2 commits)")[![sebastien-fauvel](https://avatars.githubusercontent.com/u/4215521?v=4)](https://github.com/sebastien-fauvel "sebastien-fauvel (2 commits)")[![nabab](https://avatars.githubusercontent.com/u/193892?v=4)](https://github.com/nabab "nabab (2 commits)")[![gluneaumt](https://avatars.githubusercontent.com/u/12433326?v=4)](https://github.com/gluneaumt "gluneaumt (2 commits)")[![LudoMon](https://avatars.githubusercontent.com/u/9326226?v=4)](https://github.com/LudoMon "LudoMon (1 commits)")[![Axeia](https://avatars.githubusercontent.com/u/1092845?v=4)](https://github.com/Axeia "Axeia (1 commits)")[![bryant1410](https://avatars.githubusercontent.com/u/3905501?v=4)](https://github.com/bryant1410 "bryant1410 (1 commits)")

---

Tags

parsermysqlsqlcreator

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/rob-lester-jr04-php-sql-parser/health.svg)

```
[![Health](https://phpackages.com/badges/rob-lester-jr04-php-sql-parser/health.svg)](https://phpackages.com/packages/rob-lester-jr04-php-sql-parser)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[greenlion/php-sql-parser

A pure PHP SQL (non validating) parser w/ focus on MySQL dialect of SQL

63911.6M82](/packages/greenlion-php-sql-parser)[catfan/medoo

The lightweight PHP database framework to accelerate development

4.9k1.5M194](/packages/catfan-medoo)[phpmyadmin/sql-parser

A validating SQL lexer and parser with a focus on MySQL dialect.

47950.4M55](/packages/phpmyadmin-sql-parser)[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M69](/packages/ifsnop-mysqldump-php)[cycle/orm

PHP DataMapper ORM and Data Modelling Engine

1.3k835.4k65](/packages/cycle-orm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
