Download the PHP package saada/yii2-factory-muffin without Composer
On this page you can find all versions of the php package saada/yii2-factory-muffin. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download saada/yii2-factory-muffin
More information about saada/yii2-factory-muffin
Files in saada/yii2-factory-muffin
Package yii2-factory-muffin
Short Description A Yii2 wrapper for league/factory-muffin with Gii generators.
License MIT
Homepage http://moody.website/yii2-factory-muffin/
Informations about the package yii2-factory-muffin
Yii2 Extension for Factory Muffin
I found fixtures really tiring and cumbersome to maintain with Yii2 models. So, I decided to write this extension that basically wraps FactoryMuffin and attaches factory definitions to any model that you want to seed in the database. I found it extremely helpful for seeding databases dynamically which is especially useful when writing tests. If you've used FactoryGirl or FactoryMuffin before, this is the same concept tailored for the Yii2 framework. I tried to keep things as tidy as possible. Contributions are more than welcome!
Installing
PHP 5.5+ and Composer are required.
In your composer.json, simply add these packages to your "require"
section
Example Usage
All the FactoryMuffin
API calls are accessible from the $fm
instance above.
Alternative In-Model Pattern (Optional)
This pattern is a convenience that you DO NOT HAVE TO use in your project. But I found really useful since a lot of our model definitions for tests and fake data are heavily coupled with our application models.
First, we need to implement FactoryInterface
interfaces to our models.
Now that we have our models, we can now start seeding our database from within our tests
TODO
- [x] Create wrapper around Factory Muffin 3.0
- [ ] Create Gii generator to automagically add a generic definitions() implementation to a model