{"id":20103139,"url":"https://github.com/dotkernel/dot-data-fixtures","last_synced_at":"2025-05-06T08:31:08.243Z","repository":{"id":57792010,"uuid":"527493730","full_name":"dotkernel/dot-data-fixtures","owner":"dotkernel","description":"Provide a CLI to allow fixtures ","archived":false,"fork":false,"pushed_at":"2025-02-28T05:41:23.000Z","size":124,"stargazers_count":7,"open_issues_count":0,"forks_count":3,"subscribers_count":4,"default_branch":"1.0","last_synced_at":"2025-05-04T18:51:29.571Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.dotkernel.org/dot-data-fixtures/","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/dotkernel.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-08-22T09:22:44.000Z","updated_at":"2025-02-28T05:38:45.000Z","dependencies_parsed_at":"2024-07-23T11:18:30.830Z","dependency_job_id":"a708567f-5cd3-4fb6-95f8-d35c74e82d06","html_url":"https://github.com/dotkernel/dot-data-fixtures","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":"0.15384615384615385","last_synced_commit":"651295783cf0f765d3f79b87d8d0fb52eaf43858"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-data-fixtures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-data-fixtures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-data-fixtures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dotkernel%2Fdot-data-fixtures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dotkernel","download_url":"https://codeload.github.com/dotkernel/dot-data-fixtures/tar.gz/refs/heads/1.0","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252648529,"owners_count":21782405,"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-11-13T17:34:25.148Z","updated_at":"2025-05-06T08:31:08.237Z","avatar_url":"https://github.com/dotkernel.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dot-data-fixtures\n\n`dot-data-fixtures` provides a CLI interface for interacting with doctrine/data-fixtures.\n\n\u003e dot-data-fixtures is a wrapper on top of [doctrine/data-fixtures](https://github.com/doctrine/data-fixtures)\n\n## Documentation\n\nDocumentation is available at: https://docs.dotkernel.org/dot-data-fixtures/.\n\n## Badges\n\n![OSS Lifecycle](https://img.shields.io/osslifecycle/dotkernel/dot-data-fixtures)\n![PHP from Packagist (specify version)](https://img.shields.io/packagist/php-v/dotkernel/dot-data-fixtures/1.4.0)\n\n[![GitHub issues](https://img.shields.io/github/issues/dotkernel/dot-data-fixtures)](https://github.com/dotkernel/dot-data-fixtures/issues)\n[![GitHub forks](https://img.shields.io/github/forks/dotkernel/dot-data-fixtures)](https://github.com/dotkernel/dot-data-fixtures/network)\n[![GitHub stars](https://img.shields.io/github/stars/dotkernel/dot-data-fixtures)](https://github.com/dotkernel/dot-data-fixtures/stargazers)\n[![GitHub license](https://img.shields.io/github/license/dotkernel/dot-data-fixtures)](https://github.com/dotkernel/dot-data-fixtures/blob/1.0/LICENSE)\n\n[![Build Static](https://github.com/dotkernel/dot-data-fixtures/actions/workflows/continuous-integration.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-data-fixtures/actions/workflows/continuous-integration.yml)\n[![codecov](https://codecov.io/gh/dotkernel/dot-data-fixtures/graph/badge.svg?token=PGOXZOZAB0)](https://codecov.io/gh/dotkernel/dot-data-fixtures)\n[![PHPStan](https://github.com/dotkernel/dot-data-fixtures/actions/workflows/static-analysis.yml/badge.svg?branch=1.0)](https://github.com/dotkernel/dot-data-fixtures/actions/workflows/static-analysis.yml)\n\nThis package provides a CLI interface for interacting with doctrine/data-fixtures.\n\n**Executing fixtures will **append** data to the tables.**\n\n## Requirements\n\n- **PHP**: 8.2, 8.3 or 8.4\n- **doctrine/orm**: =\u003e 3.0\n- **doctrine/data-fixtures**: =\u003e 2.0\n\n## Installation\n\nRun the following command in you project directory\n\n```shell\ncomposer require dotkernel/dot-data-fixtures\n```\n\nNext, register the package's ConfigProvider into your application config.\n\n```php\n\\Dot\\DataFixtures\\ConfigProvider::class,\n```\n\nIn `doctrine.global.php` (or your custom doctrine config file) add a new key `fixtures`, in the `doctrine` array, the value should be a valid path to a folder where your fixtures can be found.\n\n**Make sure the path is valid before proceeding to the next step.**\n\n### Example\n\n```php\nreturn [\n    'dependencies' =\u003e [ ... ],\n    'doctrine' =\u003e [\n        ...,\n        'fixtures' =\u003e getcwd() . '/data/doctrine/fixtures',\n    ],\n];\n```\n\nThe last step is to register the commands.\nWe can register the commands to work with the default CLI that doctrine provides us.\nCreate a new php file `bin/doctrine` (if you don't already have this file feel free to copy it from the below example)\n\n```php\n\u003c?php\n\nuse Doctrine\\ORM\\Tools\\Console\\ConsoleRunner;\nuse Doctrine\\ORM\\Tools\\Console\\EntityManagerProvider\\SingleManagerProvider;\n\nrequire_once 'vendor/autoload.php';\n\n$container = require getcwd() . '/config/container.php' ;\n\n$entityManager = $container-\u003eget(\\Doctrine\\ORM\\EntityManager::class);\n\n$commands = [\n    $container-\u003eget(Dot\\DataFixtures\\Command\\ExecuteFixturesCommand::class),\n    $container-\u003eget(Dot\\DataFixtures\\Command\\ListFixturesCommand::class),\n];\n\nConsoleRunner::run(\n    new SingleManagerProvider($entityManager),\n    $commands\n);\n```\n\n## Usage\n\n**List fixtures command** - will list all the available fixtures, by order of execution.\n\n````shell\nphp ./bin/doctrine fixtures:list\n````\n\n**Execute fixtures command** - this command will execute all or one fixture.\n\nTo execute all the fixtures run:\n\n```shell\nphp ./bin/doctrine fixtures:execute\n```\n\nTo execute a specific fixture run:\n\n```shell\nphp ./bin/doctrine fixtures:execute --class=RoleLoader\n```\n\n## Creating fixtures\n\nWhen creating a new fixture we have 2 requirements:\n\n- Fixtures should be created in the folder we configured earlier: `data/doctrine/fixtures`\n- Fixtures should implement `FixtureInterface` and have a `load` method.\n- Create a new php file and copy the below code-block.\n\n### Example\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nnamespace Frontend\\Fixtures;\n\nuse Doctrine\\Common\\DataFixtures\\FixtureInterface;\nuse Doctrine\\Persistence\\ObjectManager;\nuse Frontend\\User\\Entity\\UserRole;\n\n\nclass RoleLoader implements FixtureInterface\n{\n    public function load(ObjectManager $manager): void\n    {\n        $adminRole = new UserRole();\n        $adminRole-\u003esetName('admin');\n\n        $userRole = new UserRole();\n        $userRole-\u003esetName('user');\n        \n        $guestRole = new UserRole();\n        $guestRole-\u003esetName('guest');\n        \n        $manager-\u003epersist($adminRole);\n        $manager-\u003epersist($userRole);\n        $manager-\u003epersist($guestRole);\n\n        $manager-\u003eflush();\n    }\n}\n```\n\n## Ordering fixtures\n\nFixtures can we ordered using 2 methods :\n\n- by order\n- by dependencies\n\nPlease refer to this link for further details on ordering fixtures:\n\nhttps://www.doctrine-project.org/projects/doctrine-data-fixtures/en/latest/how-to/fixture-ordering.html#fixture-ordering\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotkernel%2Fdot-data-fixtures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdotkernel%2Fdot-data-fixtures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdotkernel%2Fdot-data-fixtures/lists"}