1<?php 2 3use Doctrine\DBAL\Tools\Console\ConsoleRunner; 4use Symfony\Component\Console\Helper\HelperSet; 5 6$files = [__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php']; 7$loader = null; 8$cwd = getcwd(); 9$directories = [$cwd, $cwd . DIRECTORY_SEPARATOR . 'config']; 10$configFile = null; 11 12foreach ($files as $file) { 13 if (file_exists($file)) { 14 $loader = require $file; 15 16 break; 17 } 18} 19 20if (! $loader) { 21 throw new RuntimeException('vendor/autoload.php could not be found. Did you run `php composer.phar install`?'); 22} 23 24foreach ($directories as $directory) { 25 $configFile = $directory . DIRECTORY_SEPARATOR . 'cli-config.php'; 26 27 if (file_exists($configFile)) { 28 break; 29 } 30} 31 32if (! file_exists($configFile)) { 33 ConsoleRunner::printCliConfigTemplate(); 34 35 exit(1); 36} 37 38if (! is_readable($configFile)) { 39 echo 'Configuration file [' . $configFile . '] does not have read permission.' . PHP_EOL; 40 41 exit(1); 42} 43 44$commands = []; 45$helperSet = require $configFile; 46 47if (! $helperSet instanceof HelperSet) { 48 foreach ($GLOBALS as $helperSetCandidate) { 49 if ($helperSetCandidate instanceof HelperSet) { 50 $helperSet = $helperSetCandidate; 51 52 break; 53 } 54 } 55} 56 57ConsoleRunner::run($helperSet, $commands); 58