Foundry alternatives and similar libraries
Based on the "Testing" category.
Alternatively, view foundry alternatives based on common mentions on social networks and blogs.
Pest8.9 5.1 Foundry VS PestPest is an elegant PHP testing Framework with a focus on simplicity, meticulously designed to bring back the joy of testing in PHP.
Infection7.2 9.0 Foundry VS InfectionPHP Mutation Testing library
PHP MySQL Engine4.9 0.0 Foundry VS PHP MySQL EngineA MySQL engine written in pure PHP
Access the most powerful time series database as a service
Do you think we are missing an alternative of Foundry or a related project?
Foundry makes creating fixtures data fun again, via an expressive, auto-completable, on-demand fixtures system with Symfony and Doctrine:
$post = PostFactory::new() // Create the factory for Post objects ->published() // Make the post in a "published" state ->create([ // create & persist the Post object 'slug' => 'post-a' // This Post object only requires the slug field - all other fields are random data ]) ;
The factories can be used inside DoctrineFixturesBundle to load fixtures or inside your tests, where it has even more features.
doctrine/orm (with doctrine/doctrine-bundle),
doctrine/mongodb-odm (with doctrine/mongodb-odm-bundle)
or a combination of these.
Want to watch a screencast 🎥 about it? Check out https://symfonycasts.com/foundry
How to contribute
The test suite of this library needs one or more database, and static analysis needs to be ran on the smaller PHP version supported (currently PHP 7.2), then it comes with a full docker stack.
You must install docker and install docker-compose at first before running the tests.
The library is shipped with a
Makefile to run tests.
Each target will build and start the docker stack and install composer only if needed.
$ make help validate Run fixcs, sca, full test suite and validate migrations test-full Run full PHPunit (MySQL + Mongo) test-fast Run PHPUnit with SQLite test-mysql Run PHPUnit with MySQL test-postgresql Run PHPUnit with PostgreSQL test-mongo Run PHPUnit with Mongo fixcs Run PHP-CS-Fixer sca Run static analysis database-generate-migration Generate new migration based on mapping in Zenstruck\Foundry\Tests\Fixtures\Entity database-validate-mapping Validate mapping in Zenstruck\Foundry\Tests\Fixtures\Entity database-drop-schema Drop database schema docker-start Build and run containers docker-stop Stop containers docker-purge Purge containers composer Run composer command clear Start from a fresh install (needed if vendors have already been installed with another php version)
You can run each
test-* target with a special argument
$ make test-mysql filter=FactoryTest
which will use PHPUnit's
Change docker's ports
You can create a
.env file to change the ports used by docker:
MYSQL_PORT=3307 POSTGRES_PORT=5434 MONGO_PORT=27018
Execute commands in php container
You can execute any command into the php container using docker compose:
$ docker-compose exec php [you commmand] # or "docker compose" depending on your docker compose version
Using xdebug with PhpStorm
The php container is shipped with xdebug activated. You can use step by step debugging session with PhpStorm: you should
create a server called
FOUNDRY in your PHP Remote Debug, with the IDE key
[PhpStorm with xdebug](docs/phpstorm-xdebug-config.png)
Run tests without docker
If for any reason docker is not available on your computer, the target
make test-fast will run tests with your local
php version, and sqlite will be used as database. Results may differ from the CI!
Whenever an entity in the fixtures is added or updated a migration must be generated with
The AAA style of testing was first introduced to me by Adam Wathan's excellent Test Driven Laravel Course. The inspiration for this libraries API comes from Laravel factories and christophrumpel/laravel-factories-reloaded.