<?php $loader = (require_once 'vendor/autoload.php'); $loader->add('', __DIR__ . '/api/entities'); require_once 'bootstrap.php'; $alreadyDone = array('isc'); $d = opendir('api/data/factions'); while ($f = readdir($d)) { $path = 'api/data/factions/' . $f; $infos = pathinfo($path); $extension = $infos['extension']; $filename = $infos['filename']; if (substr($f, 0, 1) != '.' && $extension == 'json') { $json = file_get_contents($path); $data = json_decode($json); $faction = $filename; if (!in_array($filename, $alreadyDone)) { echo "Doing " . $filename . "\n"; foreach ($data as $charData) { $character = new Character(); $character->setName($charData->name); $character->setFaction($faction); $character->setCost($charData->cost); $entityManager->persist($character); echo "Saved " . $charData->name . "\n"; } } } } $entityManager->flush();