We recommend to create your factories with the bake command.
Make sure to add:
$this->addPlugin('CakephpFixtureFactories');in the bootstrap method of your Application.php. See here for more details on how to load a Plugin.
The command
bin/cake bake fixture_factory -hwill assist you. You have the possibility to bake factories for all (-a) your models. You may also include help methods (-m)
based on the associations defined in your models. Factories can be baked within plugin with the command -p.