Symfony 4 - Multiple DataFixtures files

I recently upgraded a Symfony 3.3 application to Symfony 4

Part of the upgrade was loading the DataFixtures.

Symfony 4 recommends you put all your DataFixtures in a single file. I'll get around to that later. However, due to the way I organized the file system for the project, the Doctrine Fixtures Loader could not find the demo data.

Symfony 4 - Multiple DataFixtures files

To resolve the issue, I created a services_dev.yaml file with the following:

Code

services:
    App\DataFixtures\Demo\:
        resource: '../src/DataFixtures/Demo/*'
        tags: [ doctrine.fixture.orm ]

Once I added this file to the development server, the data loaded fine.

Ref: https://symfony.com/doc/master/bundles/DoctrineFixturesBundle/index.html#multiple-files