Skip to content

Instantly share code, notes, and snippets.

@vaughany
Last active January 26, 2016 23:53
Show Gist options
  • Select an option

  • Save vaughany/28fcb9b11d89fa1bcca7 to your computer and use it in GitHub Desktop.

Select an option

Save vaughany/28fcb9b11d89fa1bcca7 to your computer and use it in GitHub Desktop.
<?php
namespace App\Shell;
use Cake\Console\Shell;
/**
* DummyData shell command.
*/
class DummyDataShell extends Shell
{
/**
* main() method.
*
* @return bool|int Success or error code.
*/
public function main()
{
$this->out("Creating user populator");
$faker = \Faker\Factory::create();
$faker->addProvider(new \Faker\Provider\Internet($faker));
$entityPopulator = new \Faker\ORM\CakePHP\EntityPopulator('Users');
$populator = new \Faker\ORM\CakePHP\Populator($faker);
$populator->addEntity($entityPopulator, 20, [
'email' => function () use ($faker) { return $faker->email(); },
'password' => 'password',
]);
$this->out("Inserting");
$populator->execute(['validate' => false]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment