Doctrine Data-Fixture Module

Sat 17 Mar 2018

A couple of weeks back I've released a port for a library that we were using in our projects. It's a great library allowing you to define data to populate a database. It looked like a logical step to port and make available on Github, as there were people that have tried to port this specific library, however, none worked out of the box.

They also left bloat in there and didn't commit on Github for months, this leads me to port this on my own. The port from ZF2 to ZF3 is minor actually, the major change in migrating is that the ServiceManagers are more specific now. You used to be able to locate an FQCN with a parent ServiceManager. This ServiceManager then would, upon not finding it in its own space, check in other ServiceManagers to match the FQCN. In ZF3 this mechanic doesn't work anymore.

Factories as a whole have changed by this improvement. With this, you have to be more specific and rely less on framework "magic" which is more in line with configuration over convention I think. You can check the Github repository for the code. The hardest part for me is writing great unit tests for this project, to be honest. I would really appreciate if someone could take a look and give me some pointers on writing great unit tests.

I've checked to keep the library compatible with Symfony. In the ZF2 code, ZF and Symfony shared interfaces for cli applications. This doesn't seem the case anymore. Therefore compatibility between the two won't be possible anymore.

Data fixtures are a great way to populate the database with initial/dummy data. You can define data that you expect to be already in the database.

Lastly, I'd say when you work with Doctrine2 and ZF3, then give my lib a go. It's on Packagist!