{"id":13622689,"url":"https://github.com/zenstruck/foundry","last_synced_at":"2025-05-13T21:05:26.426Z","repository":{"id":38446007,"uuid":"265686541","full_name":"zenstruck/foundry","owner":"zenstruck","description":"A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.","archived":false,"fork":false,"pushed_at":"2025-05-12T17:09:52.000Z","size":2428,"stargazers_count":721,"open_issues_count":37,"forks_count":88,"subscribers_count":8,"default_branch":"2.x","last_synced_at":"2025-05-12T18:24:15.801Z","etag":null,"topics":["doctrine","factory","faker","fixtures","symfony","test"],"latest_commit_sha":null,"homepage":"https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html","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/zenstruck.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":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"kbond"}},"created_at":"2020-05-20T21:09:07.000Z","updated_at":"2025-05-12T17:07:01.000Z","dependencies_parsed_at":"2022-07-13T15:29:44.151Z","dependency_job_id":"3a95ac9b-2f2d-43ac-bb5a-f6a0e904f3dc","html_url":"https://github.com/zenstruck/foundry","commit_stats":{"total_commits":614,"total_committers":56,"mean_commits":"10.964285714285714","dds":"0.44462540716612375","last_synced_commit":"c8f5046a492b2d24fa2fe6130a863c652a00aadc"},"previous_names":[],"tags_count":97,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenstruck%2Ffoundry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenstruck%2Ffoundry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenstruck%2Ffoundry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zenstruck%2Ffoundry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zenstruck","download_url":"https://codeload.github.com/zenstruck/foundry/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254022437,"owners_count":22001130,"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":["doctrine","factory","faker","fixtures","symfony","test"],"created_at":"2024-08-01T21:01:22.836Z","updated_at":"2025-05-13T21:05:21.413Z","avatar_url":"https://github.com/zenstruck.png","language":"PHP","readme":"# Foundry\n\n[![CI Status](https://github.com/zenstruck/foundry/workflows/CI/badge.svg)](https://github.com/zenstruck/foundry/actions?query=workflow%3ACI)\n[![Code Coverage](https://codecov.io/gh/zenstruck/foundry/branch/master/graph/badge.svg?token=77JIFYSUC5)](https://codecov.io/gh/zenstruck/foundry)\n[![Latest Version](https://img.shields.io/packagist/v/zenstruck/foundry.svg)](https://packagist.org/packages/zenstruck/foundry)\n[![Downloads](https://img.shields.io/packagist/dm/zenstruck/foundry)](https://packagist.org/packages/zenstruck/foundry)\n\nFoundry makes creating fixtures data fun again, via an expressive, auto-completable, on-demand fixtures system with\nSymfony and Doctrine:\n\n```php\n$post = PostFactory::new() // Create the factory for Post objects\n    -\u003epublished()          // Make the post in a \"published\" state\n    -\u003ecreate([             // create \u0026 persist the Post object\n        'slug' =\u003e 'post-a' // This Post object only requires the slug field - all other fields are random data\n    ])\n;\n```\n\nThe factories can be used inside [DoctrineFixturesBundle](https://symfony.com/bundles/DoctrineFixturesBundle/current/index.html)\nto load fixtures or inside your tests, [where it has even more features](https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#using-in-your-tests).\n\nFoundry supports `doctrine/orm` (with [doctrine/doctrine-bundle](https://github.com/doctrine/doctrinebundle)),\n`doctrine/mongodb-odm` (with [doctrine/mongodb-odm-bundle](https://github.com/doctrine/DoctrineMongoDBBundle))\nor a combination of these.\n\nWant to watch a screencast 🎥 about it? Check out https://symfonycasts.com/foundry\n\n**[Read the Documentation](https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html)**\n\n**[Upgrade guide to v2](https://github.com/zenstruck/foundry/blob/v2.0.0/UPGRADE-2.0.md)**\n\n## How to contribute\n\n### Running the Test Suite\n\nThe test suite of this library needs one or more databases, then it comes with a docker compose configuration.\n\n\u003e [!NOTE]\n\u003e Docker and PHP installed locally (with `mysql`, `pgsql` \u0026 `mongodb` extensions) is required.\n\nYou can start the containers and run the test suite:\n\n```bash\n# start the container\n$ docker compose up --detach\n\n# install dependencies\n$ composer update\n\n# run main testsuite (with \"schema\" reset database strategy)\n$ composer test-schema\n# or\n$ ./phpunit\n\n# run \"migrate\" testsuite (with \"migrate\" reset database strategy)\n$ composer test-migrate\n# or\n$ ./phpunit --testsuite reset-database --bootstrap tests/bootstrap-reset-database.php\n```\n\n### Overriding the default configuration\n\nYou can override default environment variables by creating a `.env.local` file, to easily enable permutations:\n\n```bash\n# .env.local\n\n# change the database to postgreSQL...\nDATABASE_URL=\"postgresql://zenstruck:zenstruck@127.0.0.1:5433/zenstruck_foundry?serverVersion=15\"\n# ...or to SQLite\nDATABASE_URL=\"sqlite:///%kernel.project_dir%/var/data.db\"\n\nMONGO_URL=\"\" # disables Mongo\nUSE_DAMA_DOCTRINE_TEST_BUNDLE=\"1\" # enables dama/doctrine-test-bundle\nPHPUNIT_VERSION=\"11\" # possible values: 9, 10, 11, 11.4\n\n# test reset database with migrations,\n# only relevant for \"reset-database\" testsuite\nMIGRATION_CONFIGURATION_FILE=\"tests/Fixture/MigrationTests/configs/migration-configuration.php\"\n\n# run test suite with postgreSQL\n$ vendor/bin/phpunit\n```\n\nThe `.env.local` file can also be used to override the port of the database containers,\nif it does not meet your local requirements. You'll also need to override docker compose configuration:\n\nHere is an example to use MySQL on port `3308`:\n\n```yaml\n# docker-compose.override.yml\nversion: '3.9'\n\nservices:\n    mysql:\n        ports:\n            - \"3308:3306\"\n```\n\n```dotenv\n# .env.local\nDATABASE_URL=\"mysql://root:1234@127.0.0.1:3308/foundry_test?serverVersion=5.7.42\"\n```\n\n### Running the documentation linter locally\n\nThis section provides guidance on how to run the documentation linter, contained within a Docker image, locally on your machine. This linter is designed to verify and ensure that the document syntax adheres to the required standards.\n\nThe following command runs the linter in the local directory:\n\n```shell\ndocker run --rm -it -e DOCS_DIR='/docs' -v ${PWD}/docs:/docs  oskarstark/doctor-rst:latest\n```\n\n## Credit\n\nThe [AAA](https://www.thephilocoder.com/unit-testing-aaa-pattern/) style of testing was first introduced to me by\n[Adam Wathan's](https://adamwathan.me/) excellent [Test Driven Laravel Course](https://course.testdrivenlaravel.com/).\nThe inspiration for this libraries API comes from [Laravel factories](https://laravel.com/docs/master/database-testing)\nand [christophrumpel/laravel-factories-reloaded](https://github.com/christophrumpel/laravel-factories-reloaded).\n","funding_links":["https://github.com/sponsors/kbond"],"categories":["Table of Contents","PHP","目录"],"sub_categories":["Testing","测试 Testing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenstruck%2Ffoundry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzenstruck%2Ffoundry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzenstruck%2Ffoundry/lists"}