PHP code example of georgringer / faker

1. Go to this page and download the library: Download georgringer/faker 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/ */

    

georgringer / faker example snippets


$t = 'tx_myext_domain_model_xxx';

$GLOBALS['TCA'][$t]['ctrl']['faker'] = true;
$GLOBALS['TCA'][$t]['columns']['title']['faker'] = \GeorgRinger\Faker\Property\Text::getSettings([
	'from' => 15,
	'to' => 60,
]);
$GLOBALS['TCA'][$t]['columns']['description']['faker'] = \GeorgRinger\Faker\Property\Text::getSettings([
	'from' => 200,
	'to' => 300,
]);
$GLOBALS['TCA'][$t]['columns']['keywords']['faker'] = \GeorgRinger\Faker\Property\Words::getSettings([
	'min' => 3,
	'max' => 15,
]);
$GLOBALS['TCA'][$t]['columns']['bodytext']['faker'] = \GeorgRinger\Faker\Property\RealText::getSettings([
	'maxNbChars' => 200,
	'indexSize' => 2,
]);
$GLOBALS['TCA'][$t]['columns']['nothing']['faker'] = \GeorgRinger\Faker\Property\EmptyString::getSettings();
$GLOBALS['TCA'][$t]['columns']['title']['author'] = \GeorgRinger\Faker\Property\RandomElement::getSettings([
	'array' => [
		'Alice Apple',
		'Bob Banana',
		'Clive Clementine',
		'Daphne Dried-Fruit',
	],
]);
$GLOBALS['TCA'][$t]['columns']['starttime']['faker'] = \GeorgRinger\Faker\Property\Date::getSettings([
	'from' => '-1month',
	'to' => '+3month',
]);
$GLOBALS['TCA'][$t]['columns']['endtime']['faker'] = \GeorgRinger\Faker\Property\Date::getSettings([
	'from' => '-1month',
	'to' => '+3month',
]);
$GLOBALS['TCA'][$t]['columns']['hidden']['faker'] = \GeorgRinger\Faker\Property\Numeric::getSettings([
	'min' => 0,
	'max' => 1,
]);
$GLOBALS['TCA'][$t]['columns']['amount']['faker'] = \GeorgRinger\Faker\Property\Numeric::getSettings([
	'min' => 1,
	'max' => 5,
]);
$GLOBALS['TCA'][$t]['columns']['costs']['faker'] = \GeorgRinger\Faker\Property\Numeric::getSettings([
	'subtype' => 'randomFloat',
	'min' => 25,
	'max' => 100,
]);
$GLOBALS['TCA'][$t]['columns']['firstname']['faker'] = \GeorgRinger\Faker\Property\FirstName::getSettings();
$GLOBALS['TCA'][$t]['columns']['lastname']['faker'] = \GeorgRinger\Faker\Property\LastName::getSettings();
$GLOBALS['TCA'][$t]['columns']['fullname']['faker'] = \GeorgRinger\Faker\Property\FullName::getSettings();
$GLOBALS['TCA'][$t]['columns']['city']['faker'] = \GeorgRinger\Faker\Property\City::getSettings();
$GLOBALS['TCA'][$t]['columns']['zip']['faker'] = \GeorgRinger\Faker\Property\Postcode::getSettings();
$GLOBALS['TCA'][$t]['columns']['street']['faker'] = \GeorgRinger\Faker\Property\StreetAddress::getSettings();
$GLOBALS['TCA'][$t]['columns']['email']['faker'] = \GeorgRinger\Faker\Property\SafeEmail::getSettings();
$GLOBALS['TCA'][$t]['columns']['phone']['faker'] = \GeorgRinger\Faker\Property\PhoneNumber::getSettings();
$GLOBALS['TCA'][$t]['columns']['url']['faker'] = \GeorgRinger\Faker\Property\Url::getSettings();
$GLOBALS['TCA'][$t]['columns']['username']['faker'] = \GeorgRinger\Faker\Property\Username::getSettings();
$GLOBALS['TCA'][$t]['columns']['password']['faker'] = \GeorgRinger\Faker\Property\DefaultPassword::getSettings([
	'password' => '123456',
]);
$GLOBALS['TCA'][$t]['columns']['user']['faker'] = \GeorgRinger\Faker\Property\Relation::getSettings([
	'table' => 'fe_users',
	'pid' => 2, // instead of an integer this can be set to 'current' as well
	'min' => 1,
	'max' => 1,
]);