{"id":13684632,"url":"https://github.com/gourmet/faker","last_synced_at":"2025-07-26T11:31:33.199Z","repository":{"id":24203399,"uuid":"27594853","full_name":"gourmet/faker","owner":"gourmet","description":"CakePHP 3 plugin to support Faker's data generation/seeding in fixtures, migrations, etc.","archived":false,"fork":false,"pushed_at":"2016-08-20T13:58:17.000Z","size":11,"stargazers_count":18,"open_issues_count":2,"forks_count":3,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-23T15:02:37.033Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gourmet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-05T14:27:01.000Z","updated_at":"2023-01-19T04:50:56.000Z","dependencies_parsed_at":"2022-08-22T14:30:34.115Z","dependency_job_id":null,"html_url":"https://github.com/gourmet/faker","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gourmet%2Ffaker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gourmet%2Ffaker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gourmet%2Ffaker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gourmet%2Ffaker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gourmet","download_url":"https://codeload.github.com/gourmet/faker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227674006,"owners_count":17802303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-08-02T14:00:35.970Z","updated_at":"2024-12-02T05:10:05.657Z","avatar_url":"https://github.com/gourmet.png","language":"PHP","funding_links":[],"categories":["Testing"],"sub_categories":[],"readme":"# Faker\n\n[![Total Downloads](https://poser.pugx.org/gourmet/faker/downloads.svg)](https://packagist.org/packages/gourmet/faker)\n[![License](https://poser.pugx.org/gourmet/faker/license.svg)](https://packagist.org/packages/gourmet/faker)\n\nBuilt to enable [Faker] support in [CakePHP 3].\n\n## Install\n\nUsing [Composer]:\n\n```\ncomposer require gourmet/faker:~1.0\n```\n\nYou then need to load the plugin. In `boostrap.php`, something like:\n\n```php\n\\Cake\\Core\\Plugin::load('Gourmet/Faker');\n```\n\n## Examples\n\n### Fixture\n\n```php\n\u003c?php\n\nnamespace App\\Test\\Fixture;\n\nuse Gourmet\\Faker\\TestSuite\\Fixture\\TestFixture;\n\nclass PostsFixture extends TestFixture {\n\n    public $fields = [\n        'id' =\u003e ['type' =\u003e 'integer'],\n        'title' =\u003e ['type' =\u003e 'string', 'length' =\u003e 255, 'null' =\u003e false],\n        'body' =\u003e 'text',\n        'published' =\u003e ['type' =\u003e 'integer', 'default' =\u003e '0', 'null' =\u003e false],\n        'created' =\u003e 'datetime',\n        'updated' =\u003e 'datetime',\n        '_constraints' =\u003e [\n            'primary' =\u003e ['type' =\u003e 'primary', 'columns' =\u003e ['id']]\n        ]\n    ];\n\n    public $records = [\n        [\n            'id' =\u003e 1,\n            'title' =\u003e 'First Article',\n            'body' =\u003e 'First Article Body',\n            'published' =\u003e '1',\n            'created' =\u003e '2007-03-18 10:39:23',\n            'updated' =\u003e '2007-03-18 10:41:31'\n        ],\n        [\n            'id' =\u003e 2,\n            'title' =\u003e 'Second Article',\n            'body' =\u003e 'Second Article Body',\n            'published' =\u003e '1',\n            'created' =\u003e '2007-03-18 10:41:23',\n            'updated' =\u003e '2007-03-18 10:43:31'\n        ],\n        [\n            'id' =\u003e 3,\n            'title' =\u003e 'Third Article',\n            'body' =\u003e 'Third Article Body',\n            'published' =\u003e '1',\n            'created' =\u003e '2007-03-18 10:43:23',\n            'updated' =\u003e '2007-03-18 10:45:31'\n        ]\n    ];\n\n    public $number = 20;\n    public $guessers = ['\\Faker\\Guesser\\Name'];\n\n    public function init() {\n        $this-\u003ecustomColumnFormatters = [\n            'id' =\u003e function () { return $this-\u003efaker-\u003enumberBetween(count($this-\u003erecords) + 2); },\n            'published' =\u003e function () { return rand(0,3); }\n        ];\n        parent::init();\n    }\n}\n```\n\n### Migration\n\n```php\n\u003c?php\n\nuse Phinx\\Migration\\AbstractMigration;\n\nclass SeedDataMigration extends AbstractMigration {\n    public function up() {\n        $faker = Faker::create();\n        $populator = new Populator($faker);\n        $populator-\u003eaddGuesser('\\Faker\\Guesser\\Name');\n\n        $created = $modified = function () use ($faker) {\n            static $beacon;\n            $ret = $beacon;\n            if (empty($ret)) {\n                return $beacon = $faker-\u003edateTimeThisDecade();\n            }\n            $beacon = null;\n            return $ret;\n        }\n        $timestamp = compact('created', 'modified');\n\n        $roles = ['admin', 'editor', 'member'];\n\n        $populator-\u003eaddEntity('Users', 100, [\n            'email' =\u003e function () use ($faker) { return $faker-\u003esafeEmail(); },\n            'first_name' =\u003e function () use ($faker) { return $faker-\u003efirstName(); },\n            'last_name' =\u003e function () use ($faker) { return $faker-\u003elastName(); },\n            'timezone' =\u003e function () use ($faker) { return $faker-\u003etimezone(); },\n            'role' =\u003e function () use ($roles) { return $roles[array_rand($roles)]; }\n        ] + $timestamp);\n\n        $populator-\u003eexecute(['validate' =\u003e false]);\n    }\n}\n```\n\n## License\n\nCopyright (c)2015, Jad Bitar and licensed under [The MIT License][mit].\n\n[CakePHP 3]:http://cakephp.org\n[Composer]:http://getcomposer.org\n[mit]:http://www.opensource.org/licenses/mit-license.php\n[Faker]:https://github.com/fzaninotto/Faker\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgourmet%2Ffaker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgourmet%2Ffaker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgourmet%2Ffaker/lists"}