PHP code example of camspiers / silverstripe-fixturegenerator

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

    

camspiers / silverstripe-fixturegenerator example snippets


use Camspiers\SilverStripe\FixtureGenerator;

$records = //some DataObjectSet

(new FixtureGenerator\Generator(
    new FixtureGenerator\Dumpers\Yaml(
        __DIR__ . '/tests/MyFixture.yml'
    )
))->process($records);

use Camspiers\SilverStripe\FixtureGenerator;

$records = //some DataObjectSet

(new FixtureGenerator\Generator(
    new FixtureGenerator\Dumpers\Yaml(
        __DIR__ . '/tests/MyFixture.yml'
    ),
    array(
        'MyDataObject.SomeHasOneRelation',
        'MyDataObject.SomeHasManyRelation'
    )
))->process($records);

use Camspiers\SilverStripe\FixtureGenerator;

$records = //some DataObjectSet

(new FixtureGenerator\Generator(
    new FixtureGenerator\Dumpers\Yaml(
        __DIR__ . '/tests/MyFixture.yml'
    ),
    array(
        'MyDataObject.SomeHasOneRelation',
        'MyDataObject.SomeHasManyRelation'
    ),
    FixtureGenerator\Generator::RELATION_MODE_EXCLUDE
))->process($records);