PHPackages                             nextras/multi-query-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. nextras/multi-query-parser

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

nextras/multi-query-parser
==========================

Parses queries from a SQL file.

v2.0.0(2mo ago)412.4k↓11.9%2MITPHPPHP ~8.0CI passing

Since Apr 10Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/nextras/multi-query-parser)[ Packagist](https://packagist.org/packages/nextras/multi-query-parser)[ Docs](https://github.com/nextras/multi-query-parser)[ RSS](/packages/nextras-multi-query-parser/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (4)Versions (16)Used By (2)

Nextras Multi Query Parser
==========================

[](#nextras-multi-query-parser)

[![Build](https://github.com/nextras/multi-query-parser/actions/workflows/build.yml/badge.svg)](https://github.com/nextras/multi-query-parser/actions/workflows/build.yml)[![Downloads this Month](https://camo.githubusercontent.com/cbd6b2521dfcdd1f56d348f8fd40969b98f9cefb9ee3086a8dc2d13b68b1df72/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6e6578747261732f6d756c74692d71756572792d7061727365722e7376673f7374796c653d666c6174)](https://packagist.org/packages/nextras/multi-query-parser)[![Stable Version](https://camo.githubusercontent.com/1b2196dc04c079c437f8775e11c9f97a99223d28d7d759230bbcc1cabac750a7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e6578747261732f6d756c74692d71756572792d7061727365722e7376673f7374796c653d666c6174)](https://packagist.org/packages/nextras/multi-query-parser)

A streaming PHP parser for splitting multi-query SQL files into individual statements. Handles database-specific syntax like custom delimiters, dollar-quoted strings, and `BEGIN...END` blocks. The parser reads input in small chunks and yields statements one by one -- it never loads the entire file into memory, making it suitable for large SQL dumps.

### Supported Databases

[](#supported-databases)

- **MySQL** -- backtick identifiers, `DELIMITER` command, `#` comments
- **PostgreSQL** -- dollar-quoted strings (`$BODY$...$BODY$`), `E'...'` escape strings
- **SQL Server** -- `[bracketed]` identifiers, `BEGIN...END` blocks
- **SQLite** -- all three identifier styles (`"double"`, ``backtick``, `[bracket]`), `BEGIN...END` blocks for triggers

All parsers handle standard SQL comments (`--`, `/* */`), quoted strings, and semicolon delimiters.

### Installation

[](#installation)

```
composer require nextras/multi-query-parser
```

Requires PHP 8.0+.

### Usage

[](#usage)

**Parse a SQL file:**

```
use Nextras\MultiQueryParser\MySqlMultiQueryParser;

$parser = new MySqlMultiQueryParser();

foreach ($parser->parseFile('migrations.sql') as $query) {
    $connection->query($query);
}
```

**Parse a string:**

```
$sql = "CREATE TABLE users (id INT); INSERT INTO users VALUES (1);";

foreach ($parser->parseString($sql) as $query) {
    $connection->query($query);
}
```

**Parse from a file stream:**

```
$stream = fopen('migrations.sql', 'r');

foreach ($parser->parseFileStream($stream) as $query) {
    $connection->query($query);
}
```

Available parsers: `MySqlMultiQueryParser`, `PostgreSqlMultiQueryParser`, `SqlServerMultiQueryParser`, `SqliteMultiQueryParser`.

### License

[](#license)

MIT. See full [license](license.md).

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance84

Actively maintained with recent releases

Popularity31

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~1050 days

Total

2

Last Release

84d ago

Major Versions

v1.0.0 → v2.0.02026-02-24

PHP version history (2 changes)v1.0.0PHP ~7.2 || ~8.0

v2.0.0PHP ~8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/953773db6e30161b5e76572bf909c24e8ef07d7419aeebc311e071600ea99bef?d=identicon)[hrach](/maintainers/hrach)

![](https://www.gravatar.com/avatar/6163a0eec16c2bfc9cce0c7c8801b5166cca9af81a146764676059a965044000?d=identicon)[JanTvrdik](/maintainers/JanTvrdik)

---

Top Contributors

[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (29 commits)")[![hrach](https://avatars.githubusercontent.com/u/284263?v=4)](https://github.com/hrach "hrach (25 commits)")[![JanTvrdik](https://avatars.githubusercontent.com/u/175109?v=4)](https://github.com/JanTvrdik "JanTvrdik (18 commits)")

---

Tags

multi-querymysqlnextrasparserpostgresqlsqlsqlitesqlserverstreaming-dataparsersqlquerynextras

###  Code Quality

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nextras-multi-query-parser/health.svg)

```
[![Health](https://phpackages.com/badges/nextras-multi-query-parser/health.svg)](https://phpackages.com/packages/nextras-multi-query-parser)
```

###  Alternatives

[phpmyadmin/sql-parser

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

47950.4M55](/packages/phpmyadmin-sql-parser)[rennokki/laravel-eloquent-query-cache

Adding cache on your Laravel Eloquent queries' results is now a breeze.

1.1k4.0M14](/packages/rennokki-laravel-eloquent-query-cache)[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)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[nilportugues/sql-query-formatter

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

401.1M24](/packages/nilportugues-sql-query-formatter)[nilportugues/sql-query-builder

An elegant lightweight and efficient SQL QueryInterface BuilderInterface supporting bindings and complicated query generation.

425239.4k6](/packages/nilportugues-sql-query-builder)

PHPackages © 2026

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