3 use Symfony\Component\Console\Output\ConsoleOutput;
4 use Symfony\Component\Console\Input\ArrayInput;
5 use Drupal\Console\Core\Utils\ConfigurationManager;
6 use Drupal\Console\Core\Utils\ArgvInputReader;
7 use Drupal\Console\Core\Utils\DrupalFinder;
8 use Drupal\Console\Core\Style\DrupalStyle;
9 use Drupal\Console\Bootstrap\Drupal;
10 use Drupal\Console\Application;
13 ini_set('display_errors', 1);
14 ini_set('display_startup_errors', 1);
15 error_reporting(E_ALL);
19 if (file_exists(__DIR__ . '/../autoload.local.php')) {
20 include_once __DIR__ . '/../autoload.local.php';
23 __DIR__ . '/../../../autoload.php',
24 __DIR__ . '/../vendor/autoload.php'
28 foreach ($autoloaders as $file) {
29 if (file_exists($file)) {
35 if (isset($autoloader)) {
36 $autoload = include_once $autoloader;
38 echo ' You must set up the project dependencies using `composer install`' . PHP_EOL;
42 $output = new ConsoleOutput();
43 $input = new ArrayInput([]);
44 $io = new DrupalStyle($input, $output);
46 $argvInputReader = new ArgvInputReader();
47 $root = $argvInputReader->get('root', getcwd());
49 $drupalFinder = new DrupalFinder();
50 if (!$drupalFinder->locateRoot($root)) {
51 $io->error('DrupalConsole must be executed within a Drupal Site.');
56 chdir($drupalFinder->getDrupalRoot());
57 $configurationManager = new ConfigurationManager();
58 $configuration = $configurationManager
59 ->loadConfiguration($drupalFinder->getComposerRoot())
62 $debug = $argvInputReader->get('debug', false);
63 if ($configuration && $options = $configuration->get('application.options') ?: []) {
64 $argvInputReader->setOptionsFromConfiguration($options);
66 $argvInputReader->setOptionsAsArgv();
71 '<info>%s</info> version <comment>%s</comment>',
78 $drupal = new Drupal($autoload, $drupalFinder, $configurationManager);
79 $container = $drupal->boot();
82 $io->error('Something was wrong. Drupal can not be bootstrap.');
87 $application = new Application($container);
88 $application->setDrupal($drupal);