PHPackages                             maghead/sqlite-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. maghead/sqlite-parser

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

maghead/sqlite-parser
=====================

sqlite table schema parser

4.0.4(8y ago)98264[2 issues](https://github.com/maghead/sqlite-parser/issues)1MITPHPPHP &gt;=5.6

Since May 13Pushed 3y ago1 watchersCompare

[ Source](https://github.com/maghead/sqlite-parser)[ Packagist](https://packagist.org/packages/maghead/sqlite-parser)[ Docs](https://github.com/maghead/sqlite-parser)[ RSS](/packages/maghead-sqlite-parser/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (6)Used By (1)

Maghead Sqlite Parser
=====================

[](#maghead-sqlite-parser)

[![Build Status](https://camo.githubusercontent.com/bcc26bcba85fa51d720a075256175195ee37ea3634e02c84a5e49bae0ace6a29/68747470733a2f2f7472617669732d63692e6f72672f6d6167686561642f73716c6974652d7061727365722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/maghead/sqlite-parser)[![Coverage Status](https://camo.githubusercontent.com/a50b64de6cf0e9197d303f15892104eaa17e89c75bd1419663fa9fb887570fe2/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6d6167686561642f73716c6974652d7061727365722e737667)](https://coveralls.io/r/maghead/sqlite-parser)[![Latest Stable Version](https://camo.githubusercontent.com/0729cc0c34082cb3bfc6686b8f813ee8f0a669c7ab23d06cbf0e977b24782c24/68747470733a2f2f706f7365722e707567782e6f72672f6d6167686561642f73716c6974652d7061727365722f762f737461626c652e737667)](https://packagist.org/packages/maghead/sqlite-parser)[![Total Downloads](https://camo.githubusercontent.com/beaba0871143997d822b78a71a8d30a96ed9c22e4335e4641d5e9fbe811f68d2/68747470733a2f2f706f7365722e707567782e6f72672f6d6167686561642f73716c6974652d7061727365722f646f776e6c6f6164732e737667)](https://packagist.org/packages/maghead/sqlite-parser)[![Monthly Downloads](https://camo.githubusercontent.com/9ff732a5382327cf0ad1cbd27142d17a80f92418f8292a68c0abb96f0fe494ce/68747470733a2f2f706f7365722e707567782e6f72672f6d6167686561642f73716c6974652d7061727365722f642f6d6f6e74686c79)](https://packagist.org/packages/maghead/sqlite-parser)[![Daily Downloads](https://camo.githubusercontent.com/1150d9031557002c21a1a01dc3b18d707aa4aa3d171fdcbc85711171f3aa6575/68747470733a2f2f706f7365722e707567782e6f72672f6d6167686561642f73716c6974652d7061727365722f642f6461696c79)](https://packagist.org/packages/maghead/sqlite-parser)[![Latest Unstable Version](https://camo.githubusercontent.com/e3cdbc6717b3b3fc4346f8ee46c477933fe45b8dd5c40014855b923eda9fa219/68747470733a2f2f706f7365722e707567782e6f72672f6d6167686561642f73716c6974652d7061727365722f762f756e737461626c652e737667)](https://packagist.org/packages/maghead/sqlite-parser)[![License](https://camo.githubusercontent.com/72ce9e9fd504d42e288648d22e09449af19441fc040cc663f2a12070950bee35/68747470733a2f2f706f7365722e707567782e6f72672f6d6167686561642f73716c6974652d7061727365722f6c6963656e73652e737667)](https://packagist.org/packages/maghead/sqlite-parser)[![Join the chat at https://gitter.im/maghead/sqlite-parser](https://camo.githubusercontent.com/9848e94fa9f80672c00cbcf884bdb5141c34f8445b3bfb301c4c430a8866aa27/68747470733a2f2f6261646765732e6769747465722e696d2f6d6167686561642f73716c6974652d7061727365722e737667)](https://gitter.im/maghead/sqlite-parser?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)[![Works On My Machine](https://camo.githubusercontent.com/71c24a0850c0404418232a97a1a7e217d4d6377b7de352c76edb8e88458b7878/68747470733a2f2f63646e2e7261776769742e636f6d2f6e696b6b752f776f726b732d6f6e2d6d792d6d616368696e652f76302e322e302f62616467652e737667)](https://github.com/nikku/works-on-my-machine)[![Made in Taiwan](https://camo.githubusercontent.com/9ff8461912d454a52a3c2a22a80da9a976140bdb7125bb360d029ebeb755985f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d616465253230696e2d74616977616e2d677265656e2e737667)](README.md)

SYNOPSIS
========

[](#synopsis)

```
use Maghead\SqliteParser\CreateTableParser;

$sql = 'CREATE TEMP TABLE `foo` (`a` INT DEFAULT 0, name VARCHAR, address VARCHAR, CONSTRAINT address_idx UNIQUE(name, address))';

$parser = new CreateTableParser;
$def = $parser->parse($sql);

foreach ($def->columns as $c) {
    echo $c->name;
    echo $c->type;
    echo $c->primary;
}

$this->assertCount(1, $def->constraints);
$this->assertInstanceOf('Maghead\\SqliteParser\\Constraint', $def->constraints[0]);
$this->assertEquals('address_idx', $def->constraints[0]->name);
$this->assertCount(2, $def->constraints[0]->unique);
```

INSTALL
=======

[](#install)

```
composer require maghead/sqlite-parser

```

USAGE
=====

[](#usage)

Just simply call the `parse` method and you will get what you want.

`var_dump` is your friend. :-)

```
class Maghead\SqliteParser\Table#2 (5) {
  public $columns =>
  array(1) {
    [0] =>
    class Maghead\SqliteParser\Column#6 (13) {
      public $name =>
      string(1) "a"
      public $type =>
      string(3) "INT"
      public $length =>
      NULL
      public $decimals =>
      NULL
      public $unsigned =>
      bool(false)
      public $primary =>
      NULL
      public $ordering =>
      NULL
      public $autoIncrement =>
      NULL
      public $unique =>
      NULL
      public $notNull =>
      NULL
      public $default =>
      int(-20)
      public $collate =>
      NULL
      public $references =>
      NULL
    }
  }
  public $temporary =>
  bool(true)
  public $ifNotExists =>
  bool(false)
  public $tableName =>
  string(3) "foo"
  public $constraints =>
  array(1) {
    [0] =>
    class Maghead\SqliteParser\Constraint#8 (4) {
      public $name =>
      string(2) "aa"
      public $primaryKey =>
      NULL
      public $unique =>
      array(1) {
        [0] =>
        class stdClass#13 (2) {
          public $name =>
          string(1) "a"
          public $ordering =>
          string(3) "ASC"
        }
      }
      public $foreignKey =>
      NULL
    }
  }
}
```

LICENSE
=======

[](#license)

MIT LICENSE

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance16

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

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

Total

5

Last Release

3265d ago

PHP version history (2 changes)4.0.0PHP &gt;=7.0

4.0.2PHP &gt;=5.6

### Community

Maintainers

![](https://www.gravatar.com/avatar/3cc34cde233b660869ff329ed8e20df611f75dfb61aab3e30889ac153d3e5e61?d=identicon)[c9s](/maintainers/c9s)

---

Top Contributors

[![c9s](https://avatars.githubusercontent.com/u/50894?v=4)](https://github.com/c9s "c9s (34 commits)")[![NoMan2000](https://avatars.githubusercontent.com/u/812215?v=4)](https://github.com/NoMan2000 "NoMan2000 (2 commits)")

---

Tags

parserdatabasesqlitesql

### Embed Badge

![Health badge](/badges/maghead-sqlite-parser/health.svg)

```
[![Health](https://phpackages.com/badges/maghead-sqlite-parser/health.svg)](https://phpackages.com/packages/maghead-sqlite-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)[cycle/database

DBAL, schema introspection, migration and pagination

64690.9k31](/packages/cycle-database)[opis/database

A database abstraction layer over PDO, that provides a powerful and intuitive query builder, bundled with an easy to use schema builder

10184.2k3](/packages/opis-database)[delight-im/db

Safe and convenient SQL database access in a driver-agnostic way

49156.8k7](/packages/delight-im-db)

PHPackages © 2026

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