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

1.0.0-alpha.0.3.1 2016-04-18 00:00 UTC

README

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

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.