PHPackages                             palmiot/sql-splitter - 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. palmiot/sql-splitter

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

palmiot/sql-splitter
====================

Tool for split SQL databases from a file or a pipe.

1.0.0(5y ago)06MITPHPPHP &gt;=5.3.0

Since Oct 14Pushed 5y ago1 watchersCompare

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

READMEChangelog (1)DependenciesVersions (2)Used By (0)

sql-splitter
============

[](#sql-splitter)

Tool for split SQL databases from a file or a stream pipe.

Install
-------

[](#install)

```
composer require palmiot/sql-splitter
```

Usage
-----

[](#usage)

The basic are two classes, `SqlSplitter.php` and the extension `SqlSplitterCli.php`. The first do the hard work while second provide an interface for command line and allow read the output stream pipe directly from mysqldump.

### Methods of `SqlSplitter`

[](#methods-of-sqlsplitter)

The class have setters and getters for each variable but the work are of the next methods;

```
$splitter->setFrom('test/fixtures/alldatabases.sql');           // Expect a path or directory of physical file..
$splitter->setTo('./databases');                                // Set the path or directory where save the splitted databases;
$splitter->setPrefix('test');                                   // Set a prefix name for all splitted databases when them save.
$splitter->setData('CREATE DATABASE ... CREATE DATABASE ...');  // Expect an string with all databases.
$splitter->setDatabase('dbname', 'CREATE DATABASE...');         // For add manualy a database.
$splitter->split();                                             // Split and localize action of databases.
$splitter->save();                                              // Save splitted databases on .sql files to output directory.
$splitter->saveJoin();                                          // Save on a single .sql file all databases localized (the result will be similar to source).
$splitter->getLog();                                            // List all exception messages if occurred.
```

##### example

[](#example)

```
include('vendor/autoload.php'); // Using composer

use Palmiot\SqlSplitter\SqlSplitter as Splitter;

$splitter = new Splitter();
$splitter->setFrom('test/fixtures/alldatabases.sql');
$splitter->setTo('databases');
$splitter->setPrefix('test');
$splitter->split();
$splitter->save();
$splitter->saveJoin();
foreach($splitter->getLog() as $entry){
    print($entry->getMessage());
}
```

### The class `SqlSplitterCli`

[](#the-class-sqlsplittercli)

The job of this class is listen params or arguments and prepare them for pass to parent class (`SqlSplitter`) for finally request the work and return a result as string format.

The `__construct` can listen arguments (see bellow) as array format before pass to parent. The caller is the method `run()`. The basic usage is this;

##### cli.php

[](#cliphp)

```
include('src/SqlSplitter.php');
include('src/SqlSplitterCli.php');  // Including manually (if not use composer)

$work = (new Palmiot\SqlSplitter\SqlSplitterCli([]))->run();    // Listen and work

print($work);   // STDOUT
```

Once this file been written, we can send the next params from command line;

```
****************************************************************************************************************
************************************************* SQL Splitter *************************************************
****************************************************************************************************************
*                                                                                                              *
*      -i :: File .sql with all databases                                                                      *
*      --input :: /path/alldatabases.sql                                                                       *
*                                                                                                              *
*      -s :: Stream of databases                                                                               *
*      --stream :: The output of mysqldump directly                                                            *
*                                                                                                              *
*      -o :: Folder where will save the splitted databases                                                     *
*      --output :: /save/here/                                                                                 *
*                                                                                                              *
*      -p :: Apply a generic prefix for all splitted databases                                                 *
*      --prefix :: test                                                                                        *
*                                                                                                              *
*      -j :: Save all dump                                                                                     *
*      --join :: Also save the all databases as a file                                                         *
*                                                                                                              *
*      -l :: Display logs                                                                                      *
*      --logs :: if something goes wrong                                                                       *
*                                                                                                              *
*      Usage:                                                                                                  *
*                                                                                                              *
*      // from input file                                                                                      *
*      $ php cli.php -i alldatabases.sql -o databases -p test -j -l                                            *
*                                                                                                              *
*      // from dump directly                                                                                   *
*      $ mysqldump -P port -h ip -u user -ppass --opt --all-databases | php cli.php -s -o databases -j -l      *
*                                                                                                              *
****************************************************************************************************************
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity49

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

Unknown

Total

1

Last Release

2043d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/12f5f84cd6ff9242062cd630a3462d816dc958f3160f86e4b36bd84768a4ffbb?d=identicon)[palmiot](/maintainers/palmiot)

---

Top Contributors

[![palmiot](https://avatars.githubusercontent.com/u/72756629?v=4)](https://github.com/palmiot "palmiot (1 commits)")

---

Tags

streamphpsqlfilepipesplitsplitter

### Embed Badge

![Health badge](/badges/palmiot-sql-splitter/health.svg)

```
[![Health](https://phpackages.com/badges/palmiot-sql-splitter/health.svg)](https://phpackages.com/packages/palmiot-sql-splitter)
```

###  Alternatives

[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k22.9k](/packages/clouddueling-mysqldump-php)[friedolinfoerder/wp-activerecord

An ActiveRecord implementation for WordPress

237.2k](/packages/friedolinfoerder-wp-activerecord)

PHPackages © 2026

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