PHP code example of theiconic / fixtures

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

    

theiconic / fixtures example snippets


use TheIconic\Fixtures\FixtureManager\FixtureManager;

// Declare an array with the path to your fixtures
$fixtures = ['./fixtures/country.xml', './fixtures/employee.yml'];

// Create a new Fixture Manager passing such array
$fixtureManager = FixtureManager::create($fixtures);

// Persist the fixtures into your test database as follow
// Create a Default PDO Persister (currently MySQL is default)
// Here you pass host, database name, username and password
$fixtureManager->setDefaultPDOPersister('127.0.0.1', 'test_database', 'root', '123abc');

// Finally, insert fixtures into database, each table will be cleaned before insertion
$fixtureManager->persist();

// You may clean your database if needed at any point doing
$fixtureManager->cleanStorage();

$fixtureManager
    ->setDefaultPDOPersister('127.0.0.1', 'test_database', 'root', '123abc')
    ->cleanStorage()
    ->persist();

use TheIconic\Fixtures\FixtureManager\FixtureManager;

// Declare an array with the path to your fixtures
$fixtures = ['./fixtures/employee.yml'];

// Create a new Fixture Manager passing such array
$fixtureManager = FixtureManager::create(
    $fixtures,
    [
        'employee' => [
            'fx:placeholder:age' => 33
        ]
    ]
);