PHP code example of omerucel / fabrika
1. Go to this page and download the library: Download omerucel/fabrika library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
omerucel / fabrika example snippets
use Fabrika\Generator\AutoIncrement;
use Fabrika\Generator\StringSequence;
$pdo = new \PDO('mysql:host=127.0.0.1;port=3306;dbname=test;charset=utf8', 'root', '');
$connection = new Fabrika\Producer\Database\Connection\MySQL($pdo);
$producer = new Fabrika\Producer\DatabaseProducer($connection);
$producer->define('user')
->addField('id', new AutoIncrement())
->addField('username', new StringSequence('username{n}'));
$user1 = $producer->create('user');
$user2 = $producer->create('user');
assert($user1->id == 1);
assert($user1->username == 'username1');
assert($user2->id == 2);
assert($user2->username == 'username2');