springbokagency / faker-xpdo-orm-adapter
A Faker ORM adapter to populate xPDO objects with fake data
v2.0.0
2022-07-21 09:46 UTC
Requires
- fakerphp/faker: ^1.20
Requires (Dev)
- phpunit/phpunit: ^7
- xpdo/xpdo: ^3.1
This package is auto-updated.
Last update: 2025-04-16 09:27:02 UTC
README
A Faker ORM adapter to populate xPDO objects with fake data.
Table of contents
Installation
Install as development dependency using Composer.
$ composer require --dev springbokagency/faker-xpdo-orm-adapter
Usage
To populate xPDO objects, create a new populator class (using a generator instance as first parameter, and a valid xPDO instance as second parameter), then list the class and number of all the objects that must be generated. To launch the actual data population, call the execute() method.
Here is an example showing how to populate 5 modUser
and 10 modResource
objects:
<?php $generator = \Faker\Factory::create(); $populator = new \SpringbokAgency\Faker\ORM\xPDO\Populator($generator, $xpdo); $populator->addEntity(\MODX\Revolution\modUser::class, 5); $populator->addEntity(\MODX\Revolution\modResource::class, 10); $insertedPKs = $populator->execute();
For more info read the Faker documentation.