Something similar to Laravel's model factories for ZF?

We have developed some smaller projects using Laravel in the past months. We love how quick you can get up and running with a prototype that is fully tested. The model factories that Laravel offers to quickly generate test data are very convenient.

We would love to use something similar in our bigger ZF apps. I know about FactoryMuffin (https://factory-muffin.thephpleague.com/) which kinda works like Laravel’s model factories, but we would have to integrate it into ZF ourselves. At least I couldnt find a module that integrates that library or a similar one into ZF.

Is there a ZF module out there already that handles integration of FactoryMuffin (or something similar) into ZF?

I’d not heard of FactoryMuffin before your post. The project looks interesting, and I did a quick search to see if any ZF integrations exist; I didn’t find any.

It doesn’t look like it would be hard to do, though. If you manage it, please write up a tutorial, or link to examples!

It is indeed pretty simple to do, I wrote a little wrapper module for FactoryMuffin. When I have the time I may publish it on GitHub.

The only required class is League\FactoryMuffin\FactoryMuffin. You can simply add a factory to the service manager that creates a new instance of this class. My little module also offers a configuration key which other modules can use to add their own model factory definition directories (like the template path stack of Zend\View). The factory will automatically register all configured directories with the FactoryMuffin class.