PHP code example of api-skeletons / laravel-doctrine-data-fixtures

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

    

api-skeletons / laravel-doctrine-data-fixtures example snippets


$acl->hasRole($user, 'admin');

use App\ORM\Fixture\RoleFixture;

$acl->hasRole($user, RoleFixture::admin);

return [
    'default' => [  // This is the group name
        'entityManager' => EntityManager::class,
        'executor' => ORMExecutor::class,
        'purger' => ORMPurger::class,
        'fixtures' => [
            Fixture1::class,
            Fixture2::class,
        ],
    ],
];

use use Doctrine\Common\DataFixtures\Loader;

$config = config('doctrine-data-fixtures')[$groupName];

$objectManager = app($config['objectManager']);
$purger        = app($config['purger']);
$executorClass = $config['executor'];
$loader        = new Loader();

foreach ($config['fixtures'] as $fixture) {
    $loader->addFixture($fixture);
}

$executor = new $executorClass($objectManager, $purger);
$executor->execute($loader->getFixtures());
sh
php artisan vendor:publish --tag=config --provider="ApiSkeletons\Laravel\Doctrine\DataFixtures\ServiceProvider"