{"id":25821132,"url":"https://github.com/kununu/data-fixtures","last_synced_at":"2025-10-08T06:53:58.186Z","repository":{"id":45175572,"uuid":"181321888","full_name":"kununu/data-fixtures","owner":"kununu","description":"Load data fixtures in your application for any storage","archived":false,"fork":false,"pushed_at":"2025-09-26T12:19:07.000Z","size":236,"stargazers_count":7,"open_issues_count":1,"forks_count":0,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-09-26T13:13:37.922Z","etag":null,"topics":["data-fixtures","doctrine-dbal","elasticsearch","php","psr-6","symfony-httpclient"],"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/kununu.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-04-14T14:33:56.000Z","updated_at":"2025-09-26T12:16:24.000Z","dependencies_parsed_at":"2024-12-13T18:20:58.954Z","dependency_job_id":"a0da3a84-e084-425f-85fd-1383968893c4","html_url":"https://github.com/kununu/data-fixtures","commit_stats":null,"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/kununu/data-fixtures","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kununu%2Fdata-fixtures","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kununu%2Fdata-fixtures/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kununu%2Fdata-fixtures/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kununu%2Fdata-fixtures/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kununu","download_url":"https://codeload.github.com/kununu/data-fixtures/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kununu%2Fdata-fixtures/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278903034,"owners_count":26065786,"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-10-08T02:00:06.501Z","response_time":56,"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":["data-fixtures","doctrine-dbal","elasticsearch","php","psr-6","symfony-httpclient"],"created_at":"2025-02-28T10:28:40.877Z","updated_at":"2025-10-08T06:53:58.181Z","avatar_url":"https://github.com/kununu.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# kununu data-fixtures\n\nAt kununu we rely on data fixtures in our tests as well in our development and testing environments.\nA good definition of what fixtures are is the one from the documentation of [DoctrineFixturesBundle](https://symfony.com/doc/current/bundles/DoctrineFixturesBundle/index.html) in which the design and implementation of this package was heavily based on.\n\n\u003e Fixtures are used to load a “fake” set of data into a database that can then be used for testing or to help give you some interesting data while you’re developing your application.\n\n### What is kununu/data-fixtures?\n\nThis package provides a simple way to manage and execute the loading of data fixtures for any storage mechanism. It's design and implementation was heavily based on the [Doctrine data-fixtures](https://github.com/doctrine/data-fixtures) package. If you are interested in why we created this package check out [Why kununu/data-fixtures?](docs/why-kununu-data-fixtures.md).\n\n### Fixtures types\n\nCurrently, this package supports the following types of fixtures:\n\n- *[Doctrine DBAL Connection Fixtures](docs/FixtureTypes/doctrine-dbal-connection-fixtures.md)* which relies on [Doctrine DBAL](https://github.com/doctrine/dbal) by using the [Connection](https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Connection.php) implementation\n- *[Cache Pool Fixtures](docs/FixtureTypes/cache-pool-fixtures.md)* which relies on implementations of the [PSR-6](https://github.com/php-fig/cache) standard\n- *[DynamoDB Fixtures](docs/FixtureTypes/dynamodb.md)* which relies on the [AWS SDK for PHP](https://github.com/aws/aws-sdk-php) DynamoDB client\n- *[Elasticsearch Fixtures](docs/FixtureTypes/elasticsearch.md)* which relies on the [Elasticsearch-PHP client](https://www.elastic.co/guide/en/elasticsearch/client/php-api/current/index.html)\n- *[OpenSearch Fixtures](docs/FixtureTypes/opensearch.md)* which relies on the [OpenSearch PHP client](https://opensearch.org/docs/latest/clients/php/)\n- *[Symfony Http Client Fixtures](docs/FixtureTypes/symfony-http-client.md)* which relies on the [Symfony Http Client](https://github.com/symfony/http-client) and [Symfony Http Foundation](https://github.com/symfony/http-foundation).\n\nAlso check [Directory Loader](docs/FixtureTypes/directory-loader.md) to check how to load fixtures from files in a directory.\n\nIf you are interested in knowing more about the concepts of the package, or you need to create a new fixture type check out [How to create a new Fixture Type](docs/how-to-create-new-fixture-type.md).\n\n--------------------------\n## Install\n\n#### 1. Add kununu/data-fixtures to your project\n\nBefore installing this package be aware:\n- **You own the fixtures you load**\n- **This package should not be used in production mode!**\n\n```shell\ncomposer require --dev kununu/data-fixtures\n```\n\n#### 2. Enable any fixture type\n\nIn order to enable the fixture types that you are interested, check out their documentation:\n\n- [Doctrine DBAL Connection Fixtures](docs/FixtureTypes/doctrine-dbal-connection-fixtures.md)\n- [Cache Pool Fixtures](docs/FixtureTypes/cache-pool-fixtures.md)\n- [DynamoDB Fixtures](docs/FixtureTypes/dynamodb.md)\n- [Elasticsearch Fixtures](docs/FixtureTypes/elasticsearch.md)\n- [OpenSearch Fixtures](docs/FixtureTypes/opensearch.md)\n- [Symfony Http Client Fixtures](docs/FixtureTypes/symfony-http-client.md)\n\n--------------------\n\n## Append Fixtures\n\nBy default, when loading fixtures the data storage is purged. If you want to change this behavior and instead append the fixtures you can pass *false* as second argument to any executor.\n\n```php\n// By default, the data storage is purged\n$executor-\u003eexecute($loader-\u003egetFixtures());\n// If you want you can `append` the fixtures instead of purging the database\n$executor-\u003eexecute($loader-\u003egetFixtures(), true);\n```\n\n--------------------\n\n## Load Fixtures\n\nIn order to load fixtures the default [Loader](src/Loader/Loader.php) provides a couple of options:\n\n1) `loadFromDirectory(string $dir)`\n2) `loadFromFile(string $fileName)`\n3) `loadFromClassName(string $className)`\n4) `addFixture(FixtureInterface $fixture)`\n\n```php\n\u003c?php\ndeclare(strict_types=1);\n\nuse Kununu\\DataFixtures\\Loader\\ConnectionFixturesLoader;\n\n$loader = new ConnectionFixturesLoader();\n$loader-\u003eloadFromDirectory('/your/directory/');\n$loader-\u003eloadFromFile('/your/file.php');\n$loader-\u003eloadFromClassName(MyFixtureSql::class);\n$loader-\u003eaddFixture(new MyFixtureSql());\n```\n\n------------------\n\n## Initializable Fixtures\n\nIf you want your Fixture classes to be initialized you can implement the `InitializableFixtureInterface`\n\n```php\npublic function initializeFixture(mixed ...$args): void;\n```\n\nThen before loading the fixtures you need to register them in the Loader:\n\n```php\n\u003c?php\ndeclare(strict_types=1);\n\nuse Kununu\\DataFixtures\\Loader\\ConnectionFixturesLoader;\n\n$loader = new ConnectionFixturesLoader();\n\n$this-\u003eloader-\u003eregisterInitializableFixture(\n\tYourFixtureClass::class,\n\t// 1st argument\n\t1, \n\t// 2nd argument\n\t'This is an argument that will be passed to initializeFixture of YourFixtureClass',\n\t// 3rd argument\n\t[\n\t\t'field'    =\u003e 'field-name',\n\t\t'value' =\u003e 10,\n\t],\n\t// 4th argument\n\t$anInstanceOfOneOfYourOtherClasses\n\t// Pass as many arguments as you like...\n);\n\n$loader-\u003eaddFixture(new YourFixtureClass());\n```\n\n------------------------------\n\n## Contribute\n\nIf you are interested in contributing read our [contributing guidelines](CONTRIBUTING.md).\n\n------------------------------\n\n## Tests\n\nIf not yet, first install composer dependencies:\n\n```shell\ncomposer install\n```\n\nRun the tests by doing: \n\n```shell\nvendor/bin/phpunit\n```\n\nTo run tests without coverage report:\n```shell\ncomposer install\ncomposer test\n```\n\nTo run tests with coverage report:\n```shell\ncomposer install\ncomposer test-coverage\n```\n\n------------------------------\n\n![Continuous Integration](https://github.com/kununu/data-fixtures/actions/workflows/continuous-integration.yml/badge.svg)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=kununu_data-fixtures\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=kununu_data-fixtures)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkununu%2Fdata-fixtures","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkununu%2Fdata-fixtures","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkununu%2Fdata-fixtures/lists"}