Returns command that we're going to execute.

@param string $command         Command
@param bool   $background      Is it a background process?
@param bool   $sameEnvironment Run command using the same environment?
550561
protected function buildCommand(string $command, bool $background = false, bool $sameEnvironment = true): string
	{
		if($sameEnvironment && strpos($command, '--env=') === false && ($environment = $this->app->getEnvironment()) !== null)
		{
			$command .= ' --env=' . $environment;
		}

		$command = PHP_BINARY . ' ' . $this->buildReactorPath() . ' ' . $command . ' 2>&1';

		if(DIRECTORY_SEPARATOR === '\\')
		{
			if($background)
			{
				$command = '/b ' . $command;
			}

			return 'start ' . $command;
		}

		if($background)
		{
			$command .= ' &';
		}

		return $command;
	}
1021617
protected function fireAndForget(string $command, bool $sameEnvironment = true): void
	{
		pclose(popen($this->buildCommand($command, true, $sameEnvironment), 'r'));
	}
517716
public function execute($command, callable $next)
    {
        $commandName = $this->commandNameExtractor->extract($command);
        $handler = $this->handlerLocator->getHandlerForCommand($commandName);
        $methodName = $this->methodNameInflector->inflect($command, $handler);

        // is_callable is used here instead of method_exists, as method_exists
        // will fail when given a handler that relies on __call.
        if (!is_callable([$handler, $methodName])) {
            throw CanNotInvokeHandlerException::forCommand(
                $command,
                "Method '{$methodName}' does not exist on handler"
            );
        }

        return $handler->{$methodName}($command);
    }
400420
public function executeCommand(CommandInterface $command)
    {
        $this->initialize();

        if ($this->state->isCAS()) {
            return $this->client->executeCommand($command);
        }

        $response = $this->client->getConnection()->executeCommand($command);

        if ($response instanceof StatusResponse && $response == 'QUEUED') {
            $this->commands->enqueue($command);
        } elseif ($response instanceof ErrorResponseInterface) {
            throw new AbortedMultiExecException($this, $response->getMessage());
        } else {
            $this->onProtocolError('The server did not return a +QUEUED status response.');
        }

        return $this;
    }
575247
public function getCommandHandler($command)
    {
        if ($this->hasCommandHandler($command)) {
            return $this->container->make($this->handlers[get_class($command)]);
        }

        return false;
    }
977055
protected function _execute($command) {
		try {
			if (!$class = $this->_instance($command)) {
				return false;
			}
		} catch (ClassNotFoundException $e) {
			return false;
		}
		$data = [];
		$params = $class->invokeMethod('_params');

		foreach ($params as $param) {
			$data[$param] = $class->invokeMethod("_{$param}", [$this->request]);
		}

		if ($message = $class->invokeMethod('_save', [$data])) {
			$this->out($message);
			return true;
		}
		return false;
	}
820580
protected function executeEngineCommand($command, $service = null, $options = [], $quiet = false, $localhost = false)
    {
        if ($command instanceof CommandBuilder) {
            $command = $command->build();
        }
        $engine = $this->getEngineInstance();

        if ($engine instanceof DockerEngineType && !$localhost) {
            $results = $engine->execRaw($command, $service, $options, $quiet);
        } else {
            $results = $this->_exec($command);
        }

        $this->validateTaskResult($results);

        return $results;
    }
150829
public function execute($command, callable $next)
    {
        $this->entityManager->beginTransaction();

        try {
            $returnValue = $next($command);

            $this->entityManager->flush();
            $this->entityManager->commit();
        } catch (Exception $e) {
            $this->rollbackTransaction();

            throw $e;
        } catch (Throwable $e) {
            $this->rollbackTransaction();

            throw $e;
        }

        return $returnValue;
    }
420967
function runCommand($command, callable $onError = null)
    {
        $onError = $onError ?: function () {};

        // Symfony's 4.x Process component has deprecated passing a command string
        // to the constructor, but older versions (which Valet's Composer
        // constraints allow) don't have the fromShellCommandLine method.
        // For more information, see: https://github.com/laravel/valet/pull/761
        if (method_exists(Process::class, 'fromShellCommandline')) {
            $process = Process::fromShellCommandline($command);
        } else {
            $process = new Process($command);
        }

        $processOutput = '';
        $process->setTimeout(null)->run(function ($type, $line) use (&$processOutput) {
            $processOutput .= $line;
        });

        if ($process->getExitCode() > 0) {
            $onError($process->getExitCode(), $processOutput);
        }

        return $processOutput;
    }
363173
protected function executeCommand($command) {
        $class = $this->config['commands'][$command]['class'];

        if (!class_exists($class) ||
            !is_subclass_of($class, __NAMESPACE__ . '\\Command\\Executes')
        ) {
            throw new RuntimeException(sprintf(
                'Command "%s" not found',
                $command
            ), ExitApp::BAD_USER_INTERACTION);
        }

        $this->config['command'] = $command;

        /** @var Executes $command */
        $command = new $class($this->config, $this->log);

        foreach ($this->config['args'] as $help) {
            if (in_array($help, ['-h', '--help'])) {
                $command->printUsage();
                return;
            }
        }

        $command->setup()->execute()->tearDown();
    }
1314291
public function execute($command)
    {
        $deferred = new Deferred();

        if ($this->ending) {
            $deferred->reject(new RuntimeException('Shell is ending already'));
        } else {
            $this->pending []= $deferred;

            $this->sendCommand($command);
        }

        return $deferred->promise();
    }
1135683
public function execute($command, $context)
    {
        if (!$context instanceof  AnCommandContext) {
            $context = new AnCommandContext($context);
        }

        $parts = explode('.', $command);
        $method = '_'.$parts[0].'Entity'.ucfirst($parts[1]);
        $result = null;

        if (method_exists($this, $method)) {
            $result = $this->$method($context);
        }

        return $result;
    }
1189185
public function execute($command, callable $next)
    {
        if (!$command->storage) {
            throw new \LogicException("Require storage before using this middleware!");
        }

        if (!$command->secured && LoginCommand::CMD !== $command->storage->getLineActiveCmd()) {
            return $next($command);
        }

        if (!$this->isSecureExpired($command->storage)) {
            return $next($command);
        }

        $command->switchTo(LoginCommand::class);

        return $next($command);
    }
886772
public function runInBackgroundCommand(): void
    {
        $script = '<?php print_r($_SERVER); ?>';
        $ret = Sys::execInBackground("php $script");

        if ($ret === false) {
            $this->output->liteError('current env is not support process create.');
        }
    }
1026271
public function execute($command, callable $next)
    {
        if ($command instanceof FallbackCommand) {
            $command->message = new TextTemplate();
            $command->message->text = "Oops! I dont know wath you say.";
        }

        return $next($command);
    }
1061005
static function run_php($command, $background_mode = false, $ignore_duplicates = true)
    {
        if (!$ignore_duplicates || empty(self::$running_commands[$command])) {
            $config = Config::read('core');
            $php = empty($config['php']) ? 'php' : $config['php'];
            if (substr(php_uname(), 0, 7) == "Windows") {
                pclose(popen('start' . ($background_mode ? ' /B ' : ' ') . $php . ' ' . $command, "r"));
            } else {
                exec($php . ' ' . $command . ($background_mode ? " > /dev/null &" : ''));
            }
        }
        self::$running_commands[$command] = true;
    }
917981
public function handle(SingleCommand $command)
    {
        /** @var MigrationRunner $runner */
        $runner = $this->getRunner();
        $runner = $runner->withContext($command->getContext());
        $event = $runner->run(
            $command->getTarget(),
            $command->getOptions()
        );
        return $command->getVersionRepository()->update($event->getTarget());
    }