{"id":15169746,"url":"https://github.com/dmirogin/fakemodel","last_synced_at":"2025-10-01T02:31:41.283Z","repository":{"id":56970154,"uuid":"114562394","full_name":"dmirogin/fakemodel","owner":"dmirogin","description":"Make, create and store models in database. Another way to work with fixtures in Yii2. ","archived":true,"fork":false,"pushed_at":"2023-08-31T10:27:45.000Z","size":61,"stargazers_count":29,"open_issues_count":1,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-06-02T00:07:26.045Z","etag":null,"topics":["factory","fixtures","yii2-extension"],"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/dmirogin.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-12-17T19:23:09.000Z","updated_at":"2024-04-01T15:56:39.000Z","dependencies_parsed_at":"2024-09-14T03:31:50.553Z","dependency_job_id":"bd06edc4-9484-400a-b87c-0c0d40397467","html_url":"https://github.com/dmirogin/fakemodel","commit_stats":{"total_commits":29,"total_committers":5,"mean_commits":5.8,"dds":0.1724137931034483,"last_synced_commit":"bf07139fe31b64f09d3c17185b33a08aacc192bf"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/dmirogin/fakemodel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmirogin%2Ffakemodel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmirogin%2Ffakemodel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmirogin%2Ffakemodel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmirogin%2Ffakemodel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dmirogin","download_url":"https://codeload.github.com/dmirogin/fakemodel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dmirogin%2Ffakemodel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":277246265,"owners_count":25786098,"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","status":"online","status_checked_at":"2025-09-27T02:00:08.978Z","response_time":73,"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":["factory","fixtures","yii2-extension"],"created_at":"2024-09-27T07:21:58.987Z","updated_at":"2025-10-01T02:31:41.016Z","avatar_url":"https://github.com/dmirogin.png","language":"PHP","readme":"[![Build Status](https://travis-ci.org/dmirogin/fakemodel.svg?branch=master)](https://travis-ci.org/dmirogin/fakemodel)\n[![Latest Stable Version](https://poser.pugx.org/dmirogin/fakemodel/v/stable)](https://packagist.org/packages/dmirogin/fakemodel)\n[![GitHub license](https://img.shields.io/github/license/dmirogin/fakemodel.svg)](https://github.com/dmirogin/fakemodel/blob/master/LICENSE)\n\nThis package helps you to manage faked models.\nMake, create and store in database.\nThis factory is another way to work with fixtures and inspired by factories in laravel.\n\n### Requirements\n- PHP 7.0 +\n\n### Instalation\n```php\ncomposer require dmirogin/fakemodel\n```\n\n### How to use\n\n1. Add component to your application configuration\n    ```php\n    'factory' =\u003e [\n        'class' =\u003e \\dmirogin\\fakemodel\\ModelFactory::class,\n        'resolvers' =\u003e [\n            [\n                'class' =\u003e \\dmirogin\\fakemodel\\resolvers\\FakerResolver::class,\n                'definitions' =\u003e [\n                    \\app\\models\\MyModel::class =\u003e function (\\Faker\\Generator $faker) {\n                        return [\n                            'id' =\u003e $faker-\u003enumberBetween(1, 100),\n                            'username' =\u003e $faker-\u003euserName,\n                            'password' =\u003e $faker-\u003epassword\n                        ];\n                    }\n                ]\n            ]\n        ]\n    ],\n    ```\n    \n2. Now you can do:\n```php\nYii::$app-\u003efactory-\u003esetModel(\\app\\models\\MyModel::class)-\u003emake();\n```\n\n### Function in base TestCase\n\nIn your base TestCase class you can create simple function:\n```php\n/**\n * Create model factory\n *\n * @param string $model\n * @param int $amount\n * @return \\dmirogin\\fakemodel\\ModelFactory\n */\nprotected function factory(string $model, int $amount = 1): \\dmirogin\\fakemodel\\ModelFactory\n{\n    /** @var \\dmirogin\\fakemodel\\ModelFactory $factory */\n    $factory = Yii::$app-\u003efactory;\n    return $factory-\u003esetModel($model)-\u003esetAmount($amount);\n}\n```\n\nand call just by:\n```php\n$this-\u003efactory(\\app\\models\\MyModel::class)-\u003emake();\n```\n\n### Enhanced example\n\n```php\n'factory' =\u003e [\n    'class' =\u003e \\dmirogin\\fakemodel\\ModelFactory::class,\n    'resolvers' =\u003e [\n        [\n            'class' =\u003e \\dmirogin\\fakemodel\\resolvers\\FakerResolver::class,\n            'definitions' =\u003e [\n                \\app\\models\\MyModel::class =\u003e function (\\Faker\\Generator $faker) {\n                    return [\n                        'id' =\u003e $faker-\u003enumberBetween(1, 100),\n                        'username' =\u003e $faker-\u003euserName,\n                        'password' =\u003e $faker-\u003epassword\n                    ];\n                }\n            ]\n        ],\n        [\n            'class' =\u003e \\dmirogin\\fakemodel\\resolvers\\StatesResolver::class,\n            'definitions' =\u003e [\n                \\app\\models\\MyModel::class =\u003e [\n                    'admin' =\u003e [\n                        'id' =\u003e 1\n                    ]\n                ]\n            ]\n        ]\n    ]\n],\n\nYii::$app-\u003efactory-\u003esetModel(\\app\\models\\MyModel::class)-\u003estates(['admin'])-\u003esetAmount(5)-\u003emake();\n```\nSee more in [WIKI](https://github.com/dmirogin/fakemodel/wiki).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmirogin%2Ffakemodel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdmirogin%2Ffakemodel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdmirogin%2Ffakemodel/lists"}