doctrine-migrations.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. declare(strict_types=1);
  3. namespace Doctrine\Migrations;
  4. use Doctrine\Migrations\Tools\Console\ConsoleRunner;
  5. use Phar;
  6. use function extension_loaded;
  7. use function file_exists;
  8. use function fwrite;
  9. use const PHP_EOL;
  10. use const STDERR;
  11. (static function (): void {
  12. $autoloadFiles = [
  13. __DIR__ . '/../vendor/autoload.php',
  14. __DIR__ . '/../../../autoload.php',
  15. ];
  16. $autoloaderFound = false;
  17. foreach ($autoloadFiles as $autoloadFile) {
  18. if (! file_exists($autoloadFile)) {
  19. continue;
  20. }
  21. require_once $autoloadFile;
  22. $autoloaderFound = true;
  23. }
  24. if (! $autoloaderFound) {
  25. if (extension_loaded('phar') && Phar::running() !== '') {
  26. fwrite(STDERR, 'The PHAR was built without dependencies!' . PHP_EOL);
  27. exit(1);
  28. }
  29. fwrite(STDERR, 'vendor/autoload.php could not be found. Did you run `composer install`?' . PHP_EOL);
  30. exit(1);
  31. }
  32. $dependencyFactory = ConsoleRunner::findDependencyFactory();
  33. ConsoleRunner::run([], $dependencyFactory);
  34. })();