SproutCMS

This is the code documentation for the SproutCMS project

source of /scripts/dbsync.php

  1. <?php
  2. require __DIR__ . '/../vendor/autoload.php';
  3.  
  4. use Sprout\Helpers\DatabaseSync;
  5.  
  6. echo 'Sprout3 - Db Sync', PHP_EOL;
  7.  
  8. $sync = new DatabaseSync(true);
  9. $sync->loadStandardXmlFiles();
  10. $sync->sanityCheck();
  11.  
  12. if ($sync->hasLoadErrors()) {
  13. $out = strip_tags($sync->getLoadErrorsHtml());
  14. echo 'Sync failed sanity check: ' . $out, PHP_EOL;
  15. die();
  16. }
  17.  
  18. try {
  19. $log = $sync->updateDatabase();
  20. echo strip_tags($log), PHP_EOL;
  21.  
  22. if (empty($log)) {
  23. echo 'Nothing to do!', PHP_EOL;
  24. }
  25. } catch (Exception $ex) {
  26. echo $ex->getMessage(), PHP_EOL;
  27. echo 'Please configure Database.', PHP_EOL;
  28. exit(1);
  29. }
  30.