#!/usr/bin/env php getMessage(); exit(1); } class RunScriptCommand extends Command { /** @var \Magento\Framework\DB\Adapter\Pdo\Mysql */ protected $connection; protected function configure() { $bootstrap = \Magento\Framework\App\Bootstrap::create(BP, []); $objectManager = $bootstrap->getObjectManager(); $this->connection = $objectManager->get('Magento\Framework\App\ResourceConnection') ->getConnection(); $this ->setName('dev:run-script') ->setDescription('Run script'); } protected function execute(InputInterface $input, OutputInterface $output) { $output->writeln("Run script"); // Run sql queries //$rows = $this->connection->fetchAll($sql); // Load order //$order = $this->objectManager->create('Magento\Sales\Model\Order'); //$order->loadByIncrementId($orderNumber); } } try { $handler = new \Magento\Framework\App\ErrorHandler(); set_error_handler([$handler, 'handler']); $application = new Application(); $application->add(new RunScriptCommand()); $application->run(); } catch (\Exception $e) { while ($e) { echo $e->getMessage(); echo $e->getTraceAsString(); echo "\n\n"; $e = $e->getPrevious(); } exit(\Magento\Framework\Console\Cli::RETURN_FAILURE); }