cli-config.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Script needed to execute bin/doctrine.php in the command line
  5. * in order to:.
  6. *
  7. * - Generate migrations
  8. * - Create schema
  9. * - Update schema
  10. * - Validate schema
  11. * - Etc
  12. */
  13. use Doctrine\ORM\Tools\Console\ConsoleRunner;
  14. require_once __DIR__.'/vendor/autoload.php';
  15. //require_once __DIR__.'/main/inc/lib/api.lib.php';
  16. $configurationFile = __DIR__.'/app/config/configuration.php';
  17. if (!is_file($configurationFile)) {
  18. echo "File does not exists: $configurationFile";
  19. exit();
  20. }
  21. require_once $configurationFile;
  22. $database = new \Database();
  23. $dbParams = [
  24. 'driver' => 'pdo_mysql',
  25. 'host' => $_configuration['db_host'],
  26. 'user' => $_configuration['db_user'],
  27. 'password' => $_configuration['db_password'],
  28. 'dbname' => $_configuration['main_database'],
  29. ];
  30. $database->connect($dbParams, realpath(__DIR__).'/', realpath(__DIR__).'/');
  31. $entityManager = $database::getManager();
  32. $helperSet = ConsoleRunner::createHelperSet($entityManager);
  33. $dialogHelper = new Symfony\Component\Console\Helper\QuestionHelper();
  34. $helperSet->set($dialogHelper);
  35. return $helperSet;