Skip to content

Latest commit

 

History

History
32 lines (22 loc) · 1.17 KB

README.md

File metadata and controls

32 lines (22 loc) · 1.17 KB

Faker xPDO ORM Adapter

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.