PHP code example of kununu / data-fixtures

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

    

kununu / data-fixtures example snippets


// By default, the data storage is purged
$executor->execute($loader->getFixtures());
// If you want you can `append` the fixtures instead of purging the database
$executor->execute($loader->getFixtures(), true);

$loader = new Kununu\DataFixtures\Loader\ConnectionFixturesLoader();
$loader->loadFromDirectory('/your/directory/');
$loader->loadFromFile('/your/file.php');
$loader->loadFromClassName(MyFixtureSql::class);
$loader->addFixture(new MyFixtureSql());

public function initializeFixture(...$args): void;

$loader = new Kununu\DataFixtures\Loader\ConnectionFixturesLoader();

$this->loader->registerInitializableFixture(
	YourFixtureClass::class,
	// 1st argument
	1, 
	// 2nd argument
	'This is an argument that will be passed to initializeFixture of YourFixtureClass',
	// 3rd argument
	[
		'field'    => 'field-name',
		'value' => 10,
	],
	// 4th argument
	$anInstanceOfOneOfYourOtherClasses
	// Pass as many arguments as you like...
);

$loader->addFixture(new YourFixtureClass());