Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
148 lines (100 sloc) 3.34 KB



The loop, allows to generate multiple fake data in one line of code.


The num() method is also available for :doc:`complex fake data </advanced-configuration>` and fakeTable.

Fake table

The fakeTable method supports Mysql, Sqlite, PostgresSQL, Oracle, Microsoft SQL.


The database connection must be set trough configuration's values.

//mysql example
$conf['database'] = array(
    'dbname' => 'mydb',
    'user' => 'user',
    'password' => 'secret',
    'host' => 'localhost',
    'driver' => 'pdo_mysql',

//sqlite example
$conf['database'] = array(
    'path' => __DIR__ . '/mytable.sqlite',
    'driver' => 'pdo_sqlite'

For further database configuration please read the Doctrine Dbal configuration.

Fake template

Providing a [Twig]( template, Fakerino can render the template with fake data inside. the fakeTemplate method accept both file or string.

Inline template:

$fakerino->fakeTemplate('Hello Mr {{ surname }}');
//output: Hello Mr Brown

Loading external template file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
     <name>{{ namemale }}</name>
     <surname>{{ surname }}</surname>

Fake entity

The fake entity method, receive an Entity class in input and insert fake in every public properties and non public properties exposed by a public method setter.

$myEntity = new MyEntity();

//entity example
class MyEntity
    public $one;
    private $two;
    static public $four;

    public function setTwo($two)
        $this->two = $two;

Note The pubblic setter name must start with 'set' (example: setMyVar)

Regular expression

To fake a regular expression just call the fake method with the expression value.

Example: $fakerino->fake('/\d{10}/');

Ouput: 0483791034

The regular expression could be used combined with configuration values. Example:

$arrayConfig = array('surname', 'threeCharText' => '/\w{3}/');


If the seed is defined for each program run, you will receive the same fake data.

You can’t perform that action at this time.