Insert fake data into MySQL Table using PHP
Find a file
2017-02-03 17:11:28 +01:00
configs FEATURE: Add basic support for faker 2017-02-03 17:11:28 +01:00
src FEATURE: Add basic support for faker 2017-02-03 17:11:28 +01:00
.gitignore First basic working version 2017-02-03 16:55:46 +01:00
app First basic working version 2017-02-03 16:55:46 +01:00
composer.json First basic working version 2017-02-03 16:55:46 +01:00
composer.lock First basic working version 2017-02-03 16:55:46 +01:00
LICENSE Initial commit 2017-02-03 16:43:03 +01:00
readme.rst FEATURE: Add basic support for faker 2017-02-03 17:11:28 +01:00

About

Small wrapper around faker and Doctrine DBAL to seed MySQL Tables with dummy data.

Because no other found solution did work out of the box.

Installation

Run:

composer update

Usage

Provide a configuration somewhere, containing necessary database connection information and data seed information.

Call fake:mysql with configuration file and table name:

./app fake:mysql configs/typo3_downloads.yml tx_downloadcounter_domain_model_download

An example file is provided.

Userfunctions

You can define custom PHP Code to provide information for each column.

Configuration

The configuration has two sections, database and data.

database is just a plain key-value array passed to doctrines dbal. So take a look at http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html for further information.

data is a key-value pair of column names and information which data to use. The structure is like the following:

pid:
  type: static

Where pid is the column name and type defines how to get the data to use. The following types are supported:

static

Uses the value of value as static value. E.g.:

pid:
    type: static
    value: 1
userfunc

Uses a user defined function defined by class and method.

name:
    type: userfunc
    class: DSiepmann\Userfunction\RepeatingFilenames
    method: filename
faker

Uses a formatter defined by faker.

date:
    type: faker
    formatter: dateTime