1. Go to this page and download the library: Download goclearsky/name-gen library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
goclearsky / name-gen example snippets
namespace App\Shell;
use ClearSky\NameGen\Utility\Generator;
class DevShell extends Shell
{
public static function name()
{
$names = Generator::getNames(3, 'F');
$query = TableRegistry::get('Users')->query();
$query->insert(['first_name', 'last_name']);
foreach ($names as $name) {
$query->values([
'first_name' => $name['given'],
'last_name' => $name['family'],
]);
}
$query->execute();
print_r($names);
}
}
miket@dev:~/workspace/myapp $ cake dev name
Array
(
[0] => Array
(
[given] => Amy
[family] => Jones
)
[1] => Array
(
[given] => Laura
[family] => Brooks
)
[2] => Array
(
[given] => Sara
[family] => Morgan
)
)
miket@dev:~/workspace/myapp $