PHPackages                             hgg/dbcmd - 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. hgg/dbcmd

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

hgg/dbcmd
=========

Wrappter to build and execute management commands against a DB

v0.0.1(11y ago)057MITPHPPHP &gt;=5.3.3

Since Nov 7Pushed 11y ago1 watchersCompare

[ Source](https://github.com/hglattergotz/dbcmd)[ Packagist](https://packagist.org/packages/hgg/dbcmd)[ Docs](http://github.com/hglattergotz/dbcmd)[ RSS](/packages/hgg-dbcmd/feed)WikiDiscussions master Synced 4d ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Generic API for running console commands against a DB (previously hgg/dbbackup) from within a PHP application.

[![Build Status](https://camo.githubusercontent.com/d4c861a9ad500635e4922d0ecca2ddfc683cf9b440a82edaa637cb3a1d58826a/68747470733a2f2f7472617669732d63692e6f72672f68676c6174746572676f747a2f6462636d642e737667)](https://travis-ci.org/hglattergotz/dbcmd)

**Warning:** The commands are constructed containing the password in order to run non-interactive. This can be considered to be insecure.

Operations include:

- Create a database
- Drop a database
- Dump a table to a dump file
- Dump a database to a dump file
- Load a table from a dump file

Installation
------------

[](#installation)

Using Composer:

```
{
    "require": {
        "hgg/dbcmd": "dev-master"
    }
}
```

Download source and manually add to project:

- Get the zip file [here](http://github.com/hglattergotz/dbcmd/archive/master.zip)

Supported Databases:
--------------------

[](#supported-databases)

- MySql

Pull Requests for additional database engines welcome!

Usage
-----

[](#usage)

### Dump entire database

[](#dump-entire-database)

```
use HGG\DbCmd\CmdBuilder\MySql;
use HGG\DbCmd\DbCmd;

try
{
    $output = '';
    $cmd = new DbCmd(new MySql());
    $cmd->dumpDatabase('username', 'password', 'localhost', 'database',
        'dumpFile', array(), &$output);

    // log $output
}
catch (\Exception $e)
{
    // deal with failure
}
```

### Dump specific tables in a database

[](#dump-specific-tables-in-a-database)

```
use HGG\DbCmd\CmdBuilder\MySql;
use HGG\DbCmd\DbCmd;

try
{
    $output = '';
    $cmd = new DbCmd(new MySql());
    $cmd->dumpTables('username', 'password', 'localhost', 'database',
        array('table1', 'table2'), 'dumpFile', array(), &$output);

    // log $output
}
catch (\Exception $e)
{
    // deal with failure
}
```

### Restore form a dump file

[](#restore-form-a-dump-file)

```
use HGG\DbCmd\CmdBuilder\MySql;
use HGG\DbCmd\DbCmd;

try
{
    $output = '';
    $cmd = new DbCmd(new MySql());
    $cmd->load('username', 'password', 'localhost', 'database',
        'dumpFile', array(), &$output);

    // log $output
}
catch (\Exception $e)
{
    // deal with failure
}
```

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

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

4207d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/506901?v=4)[Henning Glatter-Götz](/maintainers/hglattergotz)[@hglattergotz](https://github.com/hglattergotz)

---

Top Contributors

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

---

Tags

backupdumpmysql

### Embed Badge

![Health badge](/badges/hgg-dbcmd/health.svg)

```
[![Health](https://phpackages.com/badges/hgg-dbcmd/health.svg)](https://phpackages.com/packages/hgg-dbcmd)
```

###  Alternatives

[spatie/db-dumper

Dump databases

1.2k25.9M69](/packages/spatie-db-dumper)[phpbu/phpbu

PHP Backup utility.

1.3k89.0k4](/packages/phpbu-phpbu)[rah/danpu

Zero-dependency MySQL dump library for easily exporting and importing databases

64401.8k10](/packages/rah-danpu)[cytopia/mysqldump-secure

Secure mysqldump script with encryption, compression, logging, blacklisting and Nagios monitoring integration

1474.7k1](/packages/cytopia-mysqldump-secure)[beaten-sect0r/yii2-db-manager

The db dump manager module for Yii2

9344.1k1](/packages/beaten-sect0r-yii2-db-manager)[phelium/mysql-backup

Backup easily your MySQL database !

278.2k2](/packages/phelium-mysql-backup)

PHPackages © 2026

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