dev-master
9999999-devPopulate a database with mass insertion
MIT
The Requires
by Mehdi Lahmam B.
fixtures faker
Populate a database with mass insertion
li3_populator
library let you generate fake data for your Lithium models and
save them in the database.
It provides a Lithium's ORM/ODM adapter to Faker., (*1)
Here is an example showing how to populate 50 People
data objects (instances of lithium\data\entity\Record
or lithium\data\entity\Document
), and save the
records or documents in the database., (*2)
use faker\Factory; use li3_populator\extensions\adapter\ORM\Lithium\Populator; $generator = Factory::create(); $populator = new Populator($generator); $populator->addEntity('People', 50); $people_ids = $populator->execute();
The populator will guess the relevant data for each field based on your models schema definitions., (*3)
For a more advanced usage, take a look to Faker docs., (*4)
This library is installable via Composer as mehlah/li3_populator., (*5)
Don't forget to add the library to your application in config/bootstrap/libraries.php
, (*6)
Libraries::add('li3_populator');
Populate a database with mass insertion
MIT
fixtures faker