Skip to content
/ seeder Public

🌱 Seeder is a TYPO3 Extension that generates fake data for your TYPO3 Extension. Its intended for developers only!!! This Version is an experimental version!

License

Notifications You must be signed in to change notification settings

TildBJ/seeder

Repository files navigation

seeder

Build Status Scrutinizer Code Quality Code Coverage Code Intelligence Status

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.

  1. Get seeder by running
composer require tildbj/seeder
  1. 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

0.3.1 Fix wrong vendorname in ext_emconf.php
0.3.0 * Fixes a Bug with wrong amount of relations * Feature: Possibility to configer the locale * Defined a more unique vendor name
0.2.2 * Possibility to choose between creating new data and get date which is created just now * Bugfix with recursive call
0.2.1 * Images will be created with a more unique filename so we don't have duplicates anymore
0.2.0 * Seeds can now be available in custom namespaces * You can register own provider by extending global array in ext_localconf.php * When generating seeds cli won't ask for a fieldtype for every field * Update 3rd party extension * Several Bugfixes
0.1.4 Don't return empty properties
0.1.3 * Don't override Properties anymore when calling subseeds * Removes a Bug which leads to exponentially seeder calls * Don't instanciate abstract class, if field is called abstract * Add output decorator * Always ask for a pid even if there is no TCA configuration
0.1.2 Add TYPO3 8.7 support
0.1.1 Skip start and enddate because usually we don't want to test a typo3 core feature so each record will be available in frontend
0.1.0 First experimental release

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.

About

🌱 Seeder is a TYPO3 Extension that generates fake data for your TYPO3 Extension. Its intended for developers only!!! This Version is an experimental version!

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages