{"id":18929766,"url":"https://github.com/thecodingmachine/dbfaker","last_synced_at":"2026-02-17T02:32:56.303Z","repository":{"id":66284951,"uuid":"97168654","full_name":"thecodingmachine/DBFaker","owner":"thecodingmachine","description":"Easy test data in your database !","archived":false,"fork":false,"pushed_at":"2019-12-30T11:24:51.000Z","size":99,"stargazers_count":4,"open_issues_count":3,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-20T06:24:43.669Z","etag":null,"topics":["database","dbal","fake-data","php","php7","test-data-generator"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thecodingmachine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-07-13T22:08:37.000Z","updated_at":"2025-05-06T07:14:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"caaa68ce-702f-48e8-bbe3-4e4fcf746b9e","html_url":"https://github.com/thecodingmachine/DBFaker","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thecodingmachine/DBFaker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2FDBFaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2FDBFaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2FDBFaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2FDBFaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thecodingmachine","download_url":"https://codeload.github.com/thecodingmachine/DBFaker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thecodingmachine%2FDBFaker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29531020,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-17T00:57:22.232Z","status":"online","status_checked_at":"2026-02-17T02:00:08.105Z","response_time":100,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","dbal","fake-data","php","php7","test-data-generator"],"created_at":"2024-11-08T11:35:03.706Z","updated_at":"2026-02-17T02:32:56.278Z","avatar_url":"https://github.com/thecodingmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Latest Stable Version](https://poser.pugx.org/thecodingmachine/DBFaker/v/stable)](https://packagist.org/packages/thecodingmachine/DBFaker)\n[![Total Downloads](https://poser.pugx.org/thecodingmachine/DBFaker/downloads)](https://packagist.org/packages/thecodingmachine/DBFaker)\n[![Latest Unstable Version](https://poser.pugx.org/thecodingmachine/DBFaker/v/unstable)](https://packagist.org/packages/thecodingmachine/DBFaker)\n[![License](https://poser.pugx.org/thecodingmachine/DBFaker/license)](https://packagist.org/packages/thecodingmachine/DBFaker)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/thecodingmachine/DBFaker/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/thecodingmachine/DBFaker/?branch=master)\n[![Build Status](https://travis-ci.org/thecodingmachine/DBFaker.svg?branch=master)](https://travis-ci.org/thecodingmachine/DBFaker)\n[![Coverage Status](https://coveralls.io/repos/thecodingmachine/DBFaker/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/thecodingmachine/DBFaker?branch=master)\n\n# DBFakeFiller\nAn easy to use tool to popuplate your database with fake data. Based on [doctrine/dbal](https://github.com/doctrine/dbal) so it should me cross plateforme. Fake data are generated using [fzaninotto/faker](https://github.com/fzaninotto/Faker).\n\nThis tool will parse your database schema, generate fake data and insert it inside your database. In order to generate the most valuable data, it will look into:\n* columns' types (INT, VARCHAR, TEXT, TIMESTAMP, etc.)\n* columns' attributes (precision, scale, nullable, unsigned, etc.)\n* tables' relations to create valid relation ships (obvious, else the constraints would break)\n\n\u003e **WARNING :** Always backup your database **before** running the DBFaker in case it breaks !\u003c/span\u003e\n\n## Install\n\n`composer require thecodingmachine/DBFaker`\n\n## Minimalist usage\n```php\n//instanciate the DBAL connectioin\n$connectionParams = [\n    \"host\" =\u003e \"localhost\",\n    \"user\" =\u003e \"DBU USER\",\n    \"password\" =\u003e \"DB HOST\",\n    \"port\" =\u003e null,\n    \"dbname\" =\u003e \"YOUR DB NAME\",\n    \"charset\" =\u003e \"utf8\",\n    \"driverOptions\" =\u003e array(\n        1002 =\u003e\"SET NAMES utf8\"\n    )\n];\n$conn = new \\Doctrine\\DBAL\\Connection($connectionParams, new Doctrine\\DBAL\\Driver\\PDOMySql\\Driver(), null, new \\Doctrine\\Common\\EventManager());\n\n$faker = new \\DBFaker\\DBFaker($conn);\n\n//say what tables should be filled (other tables will be considered as reference table or at least already filled)\n$faker-\u003esetFakeTableRowNumbers([\n    \"table1\" =\u003e 300, //generate 300 lines for table 1\n    \"table2\" =\u003e 20,\n    //...\n]);\n$faker-\u003efakeDB();\n```\n... now have a look at you database :) nice isn't it ?\n \n## Advanced usage\n### Custom data generators\nBy default, fake data is generated regarding the information retrieved about the column. You can pass a ```GeneratorFactory``` instance to DBFaker's\nconstructor in order to specify a custom ```FakeDataGeneratorInterface```.\n```php\n$generatorFactory = new \\DBFaker\\Generators\\GeneratorFactory();\n\n/* \nDon't hesitate to use the Faker package to generate random data,\nthere is plenty of data types available (IBAN, address, country code, ...).\nYou can evenpass the locale to generate localized data !\n*/\n$generator = \\Faker\\Factory::create();\n\n//... add your custom generators ...\n//... and injectc the Generator Factory\n$faker = new \\DBFaker\\DBFaker($conn, $generatorFactory);\n);\n```\n\n#### Customize for column\nYou may use the ```GeneratorFactory::setGeneratorForColumn()``` to set a specific generator for a given column :\n```php\n// address.postal_code column is a varchar, so default generated data will be text. Here we want a postal code :\n$generatorFactory-\u003esetGeneratorForColumn(\n    \"address\", \"postal_code\", function() use ($generator){ return $generator-\u003epostcode; }\n);\n```\n\n```setGeneratorForColumn``` takes 3 arguments : ```string $tableName``` and ```string $ColumnName``` to specify which the column and the third argument\ncan be either :\n * a ```callable``` that takes the ```\\Doctrine\\DBAL\\Schema\\Column $column``` as input parameter,\n * a ```DBFaker\\Generators\\FakeDataGeneratorInterface``` instance\n\n### Customize by condition\nFor more flexible customization, you can use ```GeneratorFactory::setGeneratorForColumn()```.\n```php\n// all columns that end with \"_email\" or are named exactly \"email\" should be emails\n$generatorFactory-\u003esetGenerator(\n    function(\\Doctrine\\DBAL\\Schema\\Column $column){\n        return preg_match(\"/([(.*_)|_|]|^)email$/\", $column-\u003egetName()) === 1;\n    }, function() use ($generator){\n        return $generator-\u003eemail;\n    }\n);\n```\nThis time, first argument is a ```callable``` that takes the ```\\Doctrine\\DBAL\\Schema\\Column $column``` as input parameter and should return a\n```boolean``` (```true``` if override should happend). The Second argument is the same as for the previous ```setGeneratorForColumn``` function.\n \n### Set null probability\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fdbfaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthecodingmachine%2Fdbfaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthecodingmachine%2Fdbfaker/lists"}