PHPackages                             datalator/datalator - 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. datalator/datalator

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

datalator/datalator
===================

Datalator: A database populator. Library to manage and populate test databases

2.0.3(4y ago)19881MITPHPPHP &gt;=7.2CI failing

Since Apr 8Pushed 4y ago1 watchersCompare

[ Source](https://github.com/oliwierptak/datalator)[ Packagist](https://packagist.org/packages/datalator/datalator)[ RSS](/packages/datalator-datalator/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (2)Dependencies (8)Versions (10)Used By (0)

About
=====

[](#about)

Datalator - very simple test database populator.

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

[](#installation)

`composer require datalator/datalator --dev`

Usage
-----

[](#usage)

### Usage in tests

[](#usage-in-tests)

```
protected function setUp()
{
    $this->databasePopulator = (new Datalator\Helper\TestPopulatorHelper())
        ->useSchemaName('default')
        ->useDataName('default')
        ->useSchemaPath('path/to/schema')
        ->useDataPath('path/to/data')
        ->populate();
}

protected function tearDown()
{
    $this->databasePopulator->rollback();
}

```

### Usage from command line

[](#usage-from-command-line)

```
 vendor/bin/datalator
  create    Create the test database. The database will dropped if it exists.
  drop      Drop the test database if it exists.
  populate  Populate the test database. The database will created / dropped if needed.

```

### Command line Configuration

[](#command-line-configuration)

Example of `.datalator` configuration file.

```
schema = default
data = default
schemaPath = schema/
dataPath = data/
; all modules are loaded by default, you can select them manually here
; modules[] = module1 ;
; modules[] = module2 ;

```

Or you can specify all options from the command line.

Data Reader
-----------

[](#data-reader)

Query `foo_one` table, use field `id` (default identity value) with value `1`, return value for `foo_one_key` column.

```
$readerConfigurator = (new ReaderConfigurator())
    ->setSource('foo_one')
    ->setIdentityValue(1)
    ->setQueryColumn('foo_one_key');

$value = $this->databasePopulator->readValue($readerConfigurator);s

$this->assertEquals('foo-one', $value->getSchemaValue());

```

Query `foo_one` table, use field `foo_one_key` with value `foo-one`, return value for `foo_one_value` column.

```
$readerConfigurator = (new ReaderConfigurator())
    ->setSource('foo_one')
    ->setIdentityValue('foo-one')
    ->setIdentityColumn('foo_one_key')
    ->setQueryColumn('foo_one_value');

$value = $this->databasePopulator->readValue($readerConfigurator);

$this->assertEquals('Foo One', $value->getDataValue());

```

Data Sources
------------

[](#data-sources)

A database table is populated from a data source, which by default is a CSV file. The schema is loaded from a SQL file.

The files are organised into folders called `modules`.

### Schema and Data Modules

[](#schema-and-data-modules)

The schema and data files are divided into modules. Each schema module has related data module.

Modules are set of tables that will be populated together in a specific order.

The organisation is very project specific. You can have as many modules and they can have as many tables as you want. Or you could just use one module for all of your tables.

#### schema module layout

[](#schema-module-layout)

Schema modules is just a folder with SQL files, containing `CREATE TABLE` statement for specific table. The name of the SQL file is the name of the database table.

#### data module layout

[](#data-module-layout)

Data module is a folder containing data source files in CSV format (by default). The name of the CSV file is the name of the table.

Besides the data files, it also contains `module.ini` file which contains information about tables managed by that module.

###### modules.ini example:

[](#modulesini-example)

```
[tables]
tables[] = foo_table

```

#### \_db module

[](#_db-module)

There is only one special module called `_db`. It consist the database schema needed for creating and dropping whole database, as well as the connection settings.

It contains 3 files:

- `create.sql`: SQL file with schema needed to create test database.
- `drop.sql`: SQL file with schema needed to drop test database.
- `database.ini`: INI file containing connection and modules settings.

###### database.ini example

[](#databaseini-example)

```
[connection]
driver = pdo_mysql
dbname = test_database
host = localhost
user = testuser
password = testpassword
port = 3306

[modules]
load[] = foo
load[] = bar
load[] = buzz
...

```

Tests
-----

[](#tests)

Run `vendor/bin/phpunit`.

See modules examples under [tests/fixtures/database](https://github.com/oliwierptak/datalator/tree/master/tests/fixtures/database).

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Recently: every ~209 days

Total

6

Last Release

1749d ago

Major Versions

1.1.0 → 2.0.02020-10-01

PHP version history (3 changes)1.0.0PHP ^7.1

2.0.0PHP ^7.2

2.0.2PHP &gt;=7.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/73a4cc056d2b09189dda46d01b76e71161dd9b75a226230bed6bec8f414d1cf8?d=identicon)[oliwierptak](/maintainers/oliwierptak)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k21.8M191](/packages/spatie-laravel-backup)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

134391.5k12](/packages/rector-rector-src)

PHPackages © 2026

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