PHP code example of dknx01 / data-fixtures

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

    

dknx01 / data-fixtures example snippets


new Configuration(pdo: $pdo, databaseName: 'foo');

new Configuration(dsn: 'mysql:host=localhost;port=3307;dbname=testdb', user: 'foo', password: 'bar', options: []);

/// your code
    $this->loadFixtures();
    $this->executeFixtures($configuration);
/// your code
 
// your code
    $fixtures = new FixtureCollection();
    $fixtures->add(new SimpleFixture());
    $handler = new FixtureHandler($configuration);
    $handler->handle($fixtures);
// your code

#[DataFixture(UserFixture::class)]
#[DataFixture(new BlaFixture(
    name: 'Test123',
    fileName: 'Test123'
))]
public function testFoo(): void
{
    // cor code
}

#[DependFixture(BarFixture::class)]
class FooFixture implements FixtureInterface, FakerAware
{
    // your code
}

// FIXTURE 1
#[\Dknx01\DataFixtures\Attributes\OrderedFixture(1)]
// FIXTURE 2
#[\Dknx01\DataFixtures\Attributes\OrderedFixture(1)]
// Result:
[
    0 => 'FIXTURE 1',
    1 => 'FIXTURE 2'
]

#[\Dknx01\DataFixtures\Attributes\OrderedFixture(0)]
class FooFixture implements FixtureInterface, FakerAware
{
    // your code
}
shell
php examples/Examples.php