Allow fixture classes to be loaded individually. #68

wants to merge 1 commit into


None yet
3 participants

malef commented Nov 17, 2012

This pull requests allows to load individual fixture classes by their class names by adding --fixture-classes option.

In some projects which require various fixture sets (e.g. for different setups for various environments) being able to point fixtures only by directory is quite a pain as some fixtures may be reused in few sets. Moving them to subdirectories doesn't solve the problem in some cases as namespaces would have to be adjusted accordingly and code would have to be duplicated. There were some issues reported concerning the lack of this feature both in this repo and in data-fixtures.

I have made a similar pull request doctrine/data-fixtures#79 to data-fixtures to allow loading individual files instead of directories and I was hoping to add this behaviour also to DoctrineFixturesBundle, but the pull request hasn't been merged yet. This pull request is another way to add similar (or maybe even better) functionality directly to DoctrineFixturesBundle, as addFixture method is already available in data-fixtures Loader class.


lsmith77 commented Nov 17, 2012

maybe it should be possible to be able to specify the class names with some glob like syntax?

malef commented Nov 17, 2012

@lsmith77 I think it would be difficult as one depends on autoloader to find and require these classes when their names are specified and they are to be instantiated. Only solution I can think of is to load or scan all fixture classes located in DataFixture/ORM directories of all bundles and later execute search with glob-like pattern on this list. However it doesn't seem very neat, does it? Can you think of any other solution?

Please note that the option I propose gives a developer full flexibility, as it can be used together with --fixtures option. So one still can load whole sets of fixtures if only they are grouped in directories.


lavoiesl commented Mar 23, 2015

Will be fixed by #97 (only by files)

@lavoiesl lavoiesl added the Duplicate label Mar 23, 2015

@lavoiesl lavoiesl closed this Mar 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment