PHPackages                             xp-forge/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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. xp-forge/sql-parser

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

xp-forge/sql-parser
===================

SQL Parser

v0.4.0(2y ago)04BSD-3-ClausePHPPHP &gt;=7.0.0

Since Nov 7Pushed 2y ago1 watchersCompare

[ Source](https://github.com/xp-forge/sql-parser)[ Packagist](https://packagist.org/packages/xp-forge/sql-parser)[ Docs](http://xp-framework.net/)[ RSS](/packages/xp-forge-sql-parser/feed)WikiDiscussions main Synced today

READMEChangelog (6)Dependencies (2)Versions (7)Used By (0)

SQL Parser
==========

[](#sql-parser)

[![Build status on GitHub](https://github.com/xp-forge/sql-parser/workflows/Tests/badge.svg)](https://github.com/xp-forge/sql-parser/actions)[![XP Framework Module](https://raw.githubusercontent.com/xp-framework/web/master/static/xp-framework-badge.png)](https://github.com/xp-framework/core)[![BSD Licence](https://raw.githubusercontent.com/xp-framework/web/master/static/licence-bsd.png)](https://github.com/xp-framework/core/blob/master/LICENCE.md)[![Requires PHP 7.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-7_0plus.svg)](http://php.net/)[![Supports PHP 8.0+](https://raw.githubusercontent.com/xp-framework/web/master/static/php-8_0plus.svg)](http://php.net/)[![Latest Stable Version](https://camo.githubusercontent.com/534a342debce8092bfa5783a14b9b132e95b5366a32d6307e7096bda173d30c6/68747470733a2f2f706f7365722e707567782e6f72672f78702d666f7267652f73716c2d7061727365722f76657273696f6e2e706e67)](https://packagist.org/packages/xp-forge/sql-parser)

This library parses SQL statements.

Examples
--------

[](#examples)

```
use text\sql\{Parser, SyntaxError};

$p= new Parser();
try {
  $statement= $p->parse('select * from user where user_id = 1');
} catch (SyntaxError $e) {
  // Handle
}

// new Select(
//   [new All()],
//   [new Table('user')],
//   new Comparison(new Field(null, 'uid'), '=', new Number(1))
// )
```

Support
-------

[](#support)

This library is not yet complete. Currently, the following are supported:

- USE database selection
- SELECT, INSERT, UPDATE and DELETE statements
- CREATE / DROP TABLE schema modification
- ALTER TABLE ADD / DROP COLUMN table modification

Other statements may be added via `extend()`:

```
use text\sql\Parser;

$p= new Parser();

// Incomplete implementation of https://dev.mysql.com/doc/refman/8.0/en/show.html
$p->extend('show', function($parse, $token) {
  return ['show' => $parse->match([
    'events'    => function($parse, $token) { return 'events'; },
    'variables' => function($parse, $token) {
      if ('like' === $parse->token->symbol->id) {
        $parse->forward();
        return ['variables' => $parse->expression()];
      } else {
        return ['variables' => null];
      }
    }
  ])];
});

$statement= $p->parse('show variables like "sql_mode"');

// ['show' => ['variables' => new Text('sql_mode')]]
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~246 days

Recently: every ~308 days

Total

6

Last Release

830d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/07d18d882c8b4aaf3466432f64018214f2771eda333202175431ee7233795376?d=identicon)[thekid](/maintainers/thekid)

---

Top Contributors

[![thekid](https://avatars.githubusercontent.com/u/696742?v=4)](https://github.com/thekid "thekid (35 commits)")

---

Tags

modulexp

### Embed Badge

![Health badge](/badges/xp-forge-sql-parser/health.svg)

```
[![Health](https://phpackages.com/badges/xp-forge-sql-parser/health.svg)](https://phpackages.com/packages/xp-forge-sql-parser)
```

###  Alternatives

[xp-framework/compiler

XP Compiler

1926.8k10](/packages/xp-framework-compiler)

PHPackages © 2026

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