tildbj / seeder
Database seeder for TYPO3
Installs: 5 485
Dependents: 0
Suggesters: 0
Security: 0
Stars: 5
Watchers: 3
Forks: 3
Open Issues: 3
Type:typo3-cms-extension
Requires
- php: ^5.5 || ^7.0 <7.2
- fzaninotto/faker: ^1.7
- typo3/cms-backend: ^7.6 || ^8.7
- typo3/cms-core: ^7.6 || ^8.7
- typo3/cms-extbase: ^7.6 || ^8.7
- typo3/cms-extensionmanager: ^7.6 || ^8.7
- typo3/cms-install: ^7.6 || ^8.7
- typo3/cms-scheduler: ^7.6 || ^8.7
Requires (Dev)
- nimut/testing-framework: ^1.1
- phpunit/phpunit: ~4.8
- squizlabs/php_codesniffer: ~2.6
- symfony/var-dumper: ^3.2
Replaces
- typo3-ter/seeder: 1.0.0-alpha.0.3.1
This package is auto-updated.
Last update: 2024-12-06 16:58:35 UTC
README
Seeder is a TYPO3 Extension that generates fake data for your TYPO3 Extension. Its intended for developers only!!! This Version is an experimental version!
Installation
via composer
The recommended way to install seeder is by using composer.
- Get seeder by running
composer require tildbj/seeder
- Activate seeder in your Extension Manager
via Extensionmanager:
Faker requires fzaninotto/faker. If you install seeder via Extensionmanager it's up to you to install fzaninotto/faker yourself.
Usage
Seeder class
Create a class wherever you want. Only make sure it's available via autoloader. Your class should look like this:
<?php namespace TildBJ\Seeder\Seeder; use TildBJ\Seeder; class Example extends \TildBJ\Seeder\Seeder\DatabaseSeeder { public function run() { $this->factory->create('tx_myextension_domain_model_mymodel')->each(function (Seeder\Seed $seed, Seeder\Faker $faker) { $seed->set( array ( 'pid' => 1, 'sys_language_uid' => 0, 'hidden' => 0, 'title' => $faker->getTitle(), 'description' => $faker->getText(), 'relation' => $this->call(\TildBJ\Seeder\Seeder\RelationExample::class), 'fal_image' => $this->call(\TildBJ\Seeder\Seeder\Image::class), ) ); }); } }
Add column information to your seed by passing an array to $seed->set([//your columns])
.
It's mandatory to provide the pid information, otherwise seeder is not able to generate any data.
Create Seed via commandline:
It's also possible to create a class via cli. Just execute the following command:
/path/to/typo3/cli_dispatch.phpsh extbase seeder:make --class-name=Example --table-name=tx_myextension_domain_model_mymodel
Attention: This command creates a seed within the directory Classes/Seeder. It's recommended to move this class outside this extensions otherwise it could get lost after an extension update.
Execute Seed:
/path/to/typo3/cli_dispatch.phpsh extbase seeder:seed \\Vendor\\Seeder\\Seeder\\Example
Alias:
Create an alias in ext_localconf.php ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['seeder']['alias']['myseed'] = \TildBJ\Seeder\Seeder\Example::class;)
for running seed like this:
/path/to/typo3/cli_dispatch.phpsh extbase seeder:seed myseed
Contributing
Contribution guidelines for this project
History
Troubleshooting
Seeder does not create any data. What am i doing wrong?
- Make sure your seed has a pid that exists in your TYPO3 installation. Otherwise the extension is not able to generate any data.
- Checkout the Logmodule in the TYPO3 backend if there is any SQL error. It can help a lot to detect wrong configuration of your seed.
Need Support?
Feel free to ask your questions on Slack
License
Seeder is released under GNU General Public License, version 3 or later. See the bundled LICENSE file for details.