randomdata
TYPO3 extensions to generate new random data or replace existing data with random data
This extensions uses https://github.com/FakerPHP/Faker and was inspired by https://github.com/georgringer/faker. Thanks go out to the builders, contributors and maintainers of those projects.
After installing randomdata in TYPO3 you can run it using the following command:
vendor/bin/typo3 randomdata:generate configuration.yaml
For more information about the command line options, use the following command:
vendor/bin/typo3 help randomdata:generate
The location of the configuration yaml file needs to be inside the site root.
For each record type you want to add to a PID you have to add configuration to the yaml file. The configuration for a single record type in a single pid looks like this:
recordTypeName:
table: recordTable
pid: recordPid
action: action
count: numberOfRecordsToCreate
fields:
field1:
provider: Provider
news
tx_news_domain_model_news
4
insert
to create new records and replace
to replace all existing records of this type for that pid. It is also possible to create custom actions.insert
. For example 10
title
Words
.A lot of Providers also require additional configuration. These can be placed on the same level as the Provider.
The following providers are available by default:
<p>
and </p>
tags [false (default), true]categories:
table: sys_category
pid: 4
action: insert
count: 10
fields:
title:
provider: Words
minimum: 1
maximum: 3
news:
table: tx_news_domain_model_news
pid: 4
action: insert
count: 20
fields:
title:
provider: Sentences
minimum: 1
maximum: 1
teaser:
provider: Sentences
minimum: 1
maximum: 30
bodytext:
provider: Paragraphs
minimum: 1
maximum: 10
html: true
datetime:
provider: DateTime
minimum: -1 year
maximum: now
format: U
categories:
provider: Relation
table: sys_category
minimum: 0
maximum: 5
fal_media:
provider: File
minimum: 0
maximum: 1
source: fileadmin/randomimages/
referenceFields:
showinpreview:
provider: FixedValue
value: 1
path_segment:
provider: FixedValue
value:
You can create a custom provider from your own extension by adding a class which implements \WIND\Randomdata\Provider\ProviderInterface
. It should have at least a static generate
method.
You can set your custom provider in the configuration yaml file by setting the full class name in the provider
option. For example provider: \My\Custom\Provider
If you need anything other than insert
or replace
as action, you can use the generateItemCustomAction
signal slot. You also need to set your action in the $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['randomdata']['allowedActions']
array.