protected function execute(InputInterface $input, OutputInterface $output) { $rc = 0; try { if (!$input->getOption('force')) { if (!$input->isInteractive()) { throw new Exception("You have to specify the --force option in order to run this command"); } $confirmQuestion = new ConfirmationQuestion('Are you sure you want to update this concrete5 installation?'); if (!$this->getHelper('question')->ask($input, $output, $confirmQuestion)) { throw new Exception("Operation aborted."); } } $configuration = new \Concrete\Core\Updater\Migrations\Configuration(); $output = new ConsoleOutput(); $configuration->setOutputWriter(new OutputWriter(function ($message) use($output) { $output->writeln($message); })); Update::updateToCurrentVersion($configuration); } catch (Exception $x) { $output->writeln('<error>' . $x->getMessage() . '</error>'); $rc = 1; } return $rc; }
/** * Handles any commandline request * * @param InputInterface $input * @return void */ public function handleRequest(InputInterface $input) { $output = new ConsoleOutput(); $this->bootstrap->loadExtensionTables(); // Check if the command to run needs a backend user to be loaded $command = $this->getCommandToRun($input); foreach ($this->availableCommands as $data) { if ($data['command'] !== $command) { continue; } if (isset($data['user'])) { $this->initializeBackendUser($data['user']); } } // Make sure output is not buffered, so command-line output and interaction can take place $this->bootstrap->endOutputBufferingAndCleanPreviousOutput(); if (!$command) { $cliKeys = array_keys($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['GLOBAL']['cliKeys']); $output->writeln('Old entrypoint keys available:'); asort($cliKeys); foreach ($cliKeys as $key => $value) { $output->writeln(' ' . $value); } $output->writeln(''); $output->writeln('TYPO3 Console Commands:'); } $exitCode = $this->application->run($input, $output); exit($exitCode); }
public static function overview() { $printer = new ConsoleOutput(); $printer->writeln(''); $printer->writeln('Testing Environment'); $printer->writeln('==================='); $printer->writeln('Machine : ' . gethostname()); $printer->writeln('Database : ' . Config::get('database.default')); }
/** * Destroy a user that matches a test user name. * * @param $role * @return $this */ public function destroyTestUser($role) { $this->output->writeln("deleting test{$role}User..."); $users = \Drupal::entityQuery('user')->condition("name", "test{$role}User")->execute(); $users = User::loadMultiple($users); foreach ($users as $user) { $user->delete(); } return $this; }
/** * Execute the product template migration */ public function execute() { $productTemplates = $this->getProductTemplates(); if (empty($productTemplates)) { $this->output->writeln('<info>There is no product template to update<info>'); return; } $this->convert($productTemplates); $this->output->writeln('<info>Done !</info>'); }
/** * @param $commands * @param \Symfony\Component\Console\Output\ConsoleOutput $output * @return void */ function execute_commands($commands, $output) { foreach ($commands as $command) { $output->writeln(sprintf('<info>Executing : </info> %s', $command)); $p = new \Symfony\Component\Process\Process($command); $exit = $p->run(function ($type, $data) use($output) { $output->write($data); }); $output->writeln(""); } }
public function processFiles($title, array $files, $process) { $o = new ConsoleOutput(); $o->writeln('<info>' . $title . '</info>'); $p = new ProgressBar($o, count($files)); $p->start(); foreach ($files as $path) { $process($path); $p->advance(); } $p->finish(); $o->writeln(''); }
/** * @inheritdoc */ public function terminate(ResultCollection $collection, ResultCollection $groupedResults) { $output = new ConsoleOutput(OutputInterface::VERBOSITY_NORMAL, true); $output->write(str_pad("\r", 80, " ")); $output->writeln(''); // score $score = $collection->getScore(); // if($score) { foreach ($score->all() as $name => $value) { $output->writeln(sprintf('%s %s', str_pad($name, 35, '.'), str_pad($value, 5, ' ', STR_PAD_LEFT) . ' / ' . Scoring::MAX)); } $output->writeln(''); // } }
/** * @param $data * @param null|int $flags */ public function dump($data, $flags = null) { if ($flags !== null) { if ($flags & self::NEWLINE_BEFORE) { $this->output->writeln(''); } } $this->cliDumper->dump($this->varCloner->cloneVar($data)); if ($flags !== null) { if ($flags & self::NEWLINE_AFTER) { $this->output->writeln(''); } } }
public function doDownLoad($limit_array) { $output = new ConsoleOutput(); // $bar = new ProgressBar($output,count($limit_array)); // $bar->start(); // $bar->setBarWidth(100); $i = 0; $count = count($limit_array); // $bar->setFormat('debug'); foreach ($limit_array as $file => $data) { // $package = $this->repository_path."/packages/".$file.".json"; $versions = $this->repository_path . "/download/" . $file . ".json"; // $package = json_decode(file_get_contents($package),true); $download = json_decode(file_get_contents($download), true); if (!$download) { $i++; $output->writeln($i . '/' . $count . ' skip'); continue; // $bar->advance(); } $i++; $versions = array_values($download['package']['versions']); if (!isset($versions[0]['require'])) { $output->writeln($i . '/' . $count . ' skip'); continue; } $output->writeln($i . '/' . $count); $package_name = strtolower($download['package']['name']); $project_name = substr($package_name, 0, strpos($package_name, '/')); // echo strpos($package_name,'/').' '.$package_name."\r\n";exit; if (isset($versions[0]['require'])) { foreach ($versions[0]['require'] as $k => $v) { R::findOrCreate("CpmRequire", array("package" => $package_name, "project" => $project_name, "require" => strtolower($k), "version" => strtolower($v))); } } if (isset($versions[0]['require-dev'])) { foreach ($versions[0]['require-dev'] as $k => $v) { R::findOrCreate("CpmRequireDev", array("package" => $package_name, "project" => $project_name, "require" => strtolower($k), "version" => strtolower($v))); } } if (isset($versions[0]['keywords'])) { foreach ($versions[0]['keywords'] as $v) { R::findOrCreate("CpmKeyword", array("package" => $package_name, "project" => $project_name, "keyword" => strtolower($v))); } } } // $bar->finish(); $output->writeln(''); }
/** * Load the external config files specified by the command line option. */ protected function loadExternalConfig() { $config = new Repository(static::getDefaultConfig()); $filesystem = new Filesystem(); foreach ($this->getConfigFiles($filesystem) as $filename) { $this->output->writeln("<info>Reading config from <path>{$filename}</path></info>"); if ($filesystem->extension($filename) == 'php') { $configValues = $filesystem->getRequire($filename); } else { $configValues = Yaml::parse($filesystem->get($filename)); } $config->set(array_dot($configValues)); } $this->container->instance('config', $config); }
/** * Print a message out - useful for debugging * * @param $string */ protected function printDebug($string) { if ($this->output === null) { $this->output = new ConsoleOutput(); } $this->output->writeln($string); }
/** * @param $commands * @param \Symfony\Component\Console\Output\ConsoleOutput $output * * @return boolean */ function execute_commands($commands, $output) { foreach ($commands as $command) { $output->writeln(sprintf('<info>Executing : </info> %s', $command)); $p = new \Symfony\Component\Process\Process($command); $p->setTimeout(null); $p->run(function ($type, $data) use($output) { $output->write($data); }); if (!$p->isSuccessful()) { return false; } $output->writeln(""); } return true; }
/** * @before */ public function runDatabaseMigrations() { if ($GLOBALS['run_database_migrations']) { return; } $GLOBALS['run_database_migrations'] = true; $output = new ConsoleOutput(); if (getenv('SCHEMA_DUMP') == 1) { $output->writeln("Cleaning Database with artisan's <bg=green;options=bold>db:fix && db:schema:dump</>..."); $this->artisan('db:fix'); $this->artisan('db:schema:dump', ['--output-file' => 'tests/_data/dump.sql', '--binary' => 'true']); } else { $output->writeln("Restoring Database with artisan's <bg=green;options=bold>db:schema:restore</>..."); $this->artisan('db:schema:restore', ['--schema-file' => 'tests/_data/dump.sql']); } }
protected function listNodes(array $nodes, $sortBy = self::SORT_BY_NAME) { switch ($sortBy) { case self::SORT_BY_NAME: usort($nodes, function ($a, $b) { return strcasecmp($a['name'], $b['name']); }); break; case self::SORT_BY_TIME: usort($nodes, function ($a, $b) { return strtotime($a['modifiedDate']) < strtotime($b['modifiedDate']); }); break; } foreach ($nodes as $node) { if ($node->inTrash() && !$this->config['display.trash']) { continue; } $modified = new \DateTime($node['modifiedDate']); if ($modified->format('Y') === date('Y')) { $date = $modified->format('M d H:m'); } else { $date = $modified->format('M d Y'); } $name = $node['kind'] === 'FOLDER' ? "<blue>{$node['name']}</blue>" : $node['name']; $this->output->writeln(sprintf("%s %s %s %s %s %s", $node['id'], $date, str_pad($node['status'], 10), str_pad($node['kind'], 7), str_pad($this->convertFilesize($node['contentProperties']['size'], 0), 6), $name)); } }
/** * @param string $name application name * @param string $version application version * @SuppressWarnings(PHPMD.ExitExpression) */ public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN') { $this->serviceManager = \Zend\Mvc\Application::init(require BP . '/setup/config/application.config.php')->getServiceManager(); $generationDirectoryAccess = new GenerationDirectoryAccess($this->serviceManager); if (!$generationDirectoryAccess->check()) { $output = new ConsoleOutput(); $output->writeln('<error>Command line user does not have read and write permissions on var/generation directory. Please' . ' address this issue before using Magento command line.</error>'); exit(0); } /** * Temporary workaround until the compiler is able to clear the generation directory * @todo remove after MAGETWO-44493 resolved */ if (class_exists(CompilerPreparation::class)) { $compilerPreparation = new CompilerPreparation($this->serviceManager, new ArgvInput(), new File()); $compilerPreparation->handleCompilerEnvironment(); } if ($version == 'UNKNOWN') { $directoryList = new DirectoryList(BP); $composerJsonFinder = new ComposerJsonFinder($directoryList); $productMetadata = new ProductMetadata($composerJsonFinder); $version = $productMetadata->getVersion(); } parent::__construct($name, $version); }
public function checkDependencies() { $output = new ConsoleOutput(); if (!extension_loaded('mbstring')) { $output->writeln("\n<error>Missing Dependency: Please install the Multibyte String Functions.</error>\n" . "More help: http://www.php.net/manual/en/mbstring.installation.php\n", $this->outputFormat); exit(1); } }
/** * Run the dotenv diff */ public static function run() { $output = new ConsoleOutput(); $formatter = new FormatterHelper(); $env = self::readFile('.env'); $envExample = self::readFile('.env.example'); // Check which variables are missing and which ones are extra $envKeys = array_keys($env); $envExampleKeys = array_keys($envExample); $missing = array_diff($envExampleKeys, $envKeys); $extra = array_diff($envKeys, $envExampleKeys); if (count($missing) > 0 || count($extra) > 0) { $output->writeln(''); $warning = $formatter->formatBlock('Warning: Your .env and .env.example files are not in sync.', 'bg=blue;fg=white', true); $output->writeln($warning); } if (count($missing) > 0) { $output->writeln("\n<comment>The following variables are missing from your .env file:<comment>"); foreach ($missing as $variable) { $output->writeln(sprintf('<info>%s=%s<info>', $variable, $envExample[$variable])); } } if (count($extra) > 0) { $output->writeln("\n<comment>The following variables are in your .env file but not in .env.example:<comment>"); foreach ($extra as $variable) { $output->writeln(sprintf('<info>%s=%s<info>', $variable, $env[$variable])); } } $output->writeln(''); }
private static function printMessage($s, $tag) { if (PHP_SAPI === 'cli') { $output = new ConsoleOutput(); $output->writeln('<' . $tag . '>' . $s . '</' . $tag . '>'); } else { error_log(strtoupper($tag) . ': ' . $s); } }
/** * Starts shell */ public function run() { $this->application->setAutoExit(false); $this->application->setCatchExceptions(true); $this->output->writeln($this->getHeader()); $php = null; while (true) { $command = $this->readline(); if (false === $command) { $this->output->writeln("\n"); break; } $ret = $this->application->run(new StringInput($command), $this->output); if (0 !== $ret) { $this->output->writeln(sprintf('<error>The command terminated with an error status (%s)</error>', $ret)); } } }
public static function postInstall(Event $event) { $vendor_dir = $event->getComposer()->getConfig()->get('vendor-dir'); //tinymce taalbestanden in lib dir plaatsen if (!file_exists($vendor_dir . "/tinymce/tinymce/jscripts/tiny_mce/langs/nl.js")) { $output = new output(); $output->writeln('<info>copying tinyMCE language files into ' . $vendor_dir . '/tinymce/tinymce/jscripts/tiny_mce</info>'); passthru("cp -af " . $vendor_dir . "/bugbyte/composereventhandler/lib/tinymce_lang_pack/* " . $vendor_dir . "/tinymce/tinymce/jscripts/tiny_mce"); } }
/** * Registers services on the given app. * * This method should only be used to configure services and parameters. * It should not get services. * * @param Application $app An Application instance */ public function register(Application $app) { $app['migrations.output_writer'] = new OutputWriter(function ($message) { $output = new ConsoleOutput(); $output->writeln($message); }); $app['migrations.directory'] = null; $app['migrations.name'] = 'Migrations'; $app['migrations.namespace'] = null; $app['migrations.table_name'] = 'migration_versions'; }
public static function install() { $output = new ConsoleOutput(); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $output->writeln("<info>Sorry, automated installation is not yet supported on Windows!</info>"); $output->writeln("Please refer to the documentation for alternative installation methods: http://developer.joomlatools.com/platform/getting-started.html"); return; } $input = new ArgvInput(); if ($input->hasParameterOption(array('--no-interaction', '-n'))) { return; } $cwd = getcwd(); $www = dirname($cwd); $site = basename($cwd); $arguments = array('site:install', 'site' => $site, '--www' => $www, '--interactive' => true, '--mysql_db_prefix' => ''); $output->writeln("<info>Welcome to the Joomlatools Platform installer!</info>"); $output->writeln("Fill in the following details to configure your new application."); $application = new Application(); $application->run(new ArrayInput($arguments)); }
public function handle(Args $args, IO $io, Command $command) { $output = new ConsoleOutput(); $style = new OutputFormatterStyle('white', 'black', array('bold')); if ($args->getArgument('package') == '') { $output->writeln(Cpm\message::USAGE); exit; } if (!file_exists('composer.json')) { $output->writeln(Cpm\message::NOComposerJSON); } $json = file_get_contents('composer.json'); $array = json_decode($json, TRUE); $datas = $array['require']; foreach ($datas as $data) { $output->getFormatter()->setStyle('bold', $style); $output->writeln('<bold>' . $data->name . '</>' . ' ' . $data->description); $output->writeln($data->keywords); } return 0; }
/** * Runs the current application. * * @param InputInterface $input An InputInterface instance * @param OutputInterface $output An OutputInterface instance * * @return integer 0 if everything went fine, or an error code * * @throws \Exception on problems */ public function run(InputInterface $input = null, OutputInterface $output = null) { try { parent::run($input, $output); } catch (\Exception $e) { if (null === $output) { $output = new ConsoleOutput(); } $message = array($this->getLongVersion(), '', $e->getMessage(), ''); $output->writeln($message); } }
/** * install * * @return void */ public static function install() { $output = new ConsoleOutput(); $style = new OutputFormatterStyle('green'); $output->getFormatter()->setStyle('green', $style); $assets = array('resources/cache', 'resources/log', 'web/assets'); foreach ($assets as $asset) { self::createAndChmod($asset, 0777); $output->writeln(sprintf('<green>Generating "%s" asset dir</green>', $asset)); } exec('php console assetic:dump'); }
/** * return a collection of arrays of assets paths found * in the included directories, except all ignored * (directories, patterns, extensions and files). * * @param AssetInterface $asset_holder * * @return Collection */ public function read(AssetInterface $asset_holder) { /* * add the included directories and files */ $this->includeThis($asset_holder); /* * exclude the ignored directories and files */ $this->excludeThis($asset_holder); // user terminal message $this->console->writeln('<fg=yellow>Files to upload:</fg=yellow>'); // get all allowed 'for upload' files objects (assets) and store them in an array $assets = []; foreach ($this->files() as $file) { // user terminal message $this->console->writeln('<fg=cyan>' . 'Path: ' . $file->getRealpath() . '</fg=cyan>'); $assets[] = $file; } return new Collection($assets); }
/** * {@inheritDoc} */ public function load(ObjectManager $manager) { /** @var KernelInterface $kernel */ $kernel = $this->container->get('kernel'); if (in_array($kernel->getEnvironment(), $this->getEnvironments())) { $this->doLoad($manager); } else { $ouput = new ConsoleOutput(); $msg = '...Not for ' . $kernel->getEnvironment() . ' environment'; $ouput->writeln(' <comment>></comment> <comment>' . $msg . '</comment>'); } }
/** * Send an E-mail signup confirmation * @param mixin $user */ public function sendConfirmEmail($user) { Mail::send('emails.confirmation', ['user' => $user, 'confirmationLink' => url('/ulibier/activated?token=' . base64_encode(serialize($user)))], function ($m) use($user) { $m->from('*****@*****.**', 'Ulibi'); $m->to($user['email'], $user['firstname'] . ' ' . $user['lastname'])->subject('Ulibi sign-up confirmation'); }); $email = $user['email']; $output = new ConsoleOutput(); $output->writeln(<<<ENDDOC <info>Message sent to {$email} :)</info> ENDDOC ); }
/** * @return bool */ private function changeUser() { $user = $this->container->getConfig()->get('command.user'); // Bypass cache commands as we need the sudoer user to run the commands if (null !== $user && (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !== 'flushall') && (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !== 'redis:flushall') && (!isset($_SERVER['argv'][1]) || $_SERVER['argv'][1] !== 'apc:flushall')) { $name = $user; $user = posix_getpwnam($user); posix_setgid($user['gid']); posix_setuid($user['uid']); if (posix_geteuid() !== (int) $user['uid']) { $output = new ConsoleOutput(); $formatter = new FormatterHelper(); $output->writeln('', true); $errorMessages = array('', ' [Error] ', ' Could not change user to ' . $name . ' ', ''); $formattedBlock = $formatter->formatBlock($errorMessages, 'error'); $output->writeln($formattedBlock); $output->writeln('', true); return false; } } return true; }