Neos\Flow\Core\Booting\Scripts::buildPhpCommand PHP Метод

buildPhpCommand() публичный статический Метод

public static buildPhpCommand ( array $settings ) : string
$settings array The Neos.Flow settings
Результат string A command line command for PHP, which can be extended and then exec()uted
    public static function buildPhpCommand(array $settings)
    {
        $subRequestEnvironmentVariables = ['FLOW_ROOTPATH' => FLOW_PATH_ROOT, 'FLOW_PATH_TEMPORARY_BASE' => FLOW_PATH_TEMPORARY_BASE, 'FLOW_CONTEXT' => $settings['core']['context']];
        if (isset($settings['core']['subRequestEnvironmentVariables'])) {
            $subRequestEnvironmentVariables = array_merge($subRequestEnvironmentVariables, $settings['core']['subRequestEnvironmentVariables']);
        }
        $command = '';
        foreach ($subRequestEnvironmentVariables as $argumentKey => $argumentValue) {
            if (DIRECTORY_SEPARATOR === '/') {
                $command .= sprintf('%s=%s ', $argumentKey, escapeshellarg($argumentValue));
            } else {
                // SET does not parse out quotes, hence we need escapeshellcmd here instead
                $command .= sprintf('SET %s=%s&', $argumentKey, escapeshellcmd($argumentValue));
            }
        }
        if (DIRECTORY_SEPARATOR === '/') {
            $phpBinaryPathAndFilename = '"' . escapeshellcmd(Files::getUnixStylePath($settings['core']['phpBinaryPathAndFilename'])) . '"';
        } else {
            $phpBinaryPathAndFilename = escapeshellarg(Files::getUnixStylePath($settings['core']['phpBinaryPathAndFilename']));
        }
        $command .= $phpBinaryPathAndFilename;
        if (!isset($settings['core']['subRequestPhpIniPathAndFilename']) || $settings['core']['subRequestPhpIniPathAndFilename'] !== false) {
            if (!isset($settings['core']['subRequestPhpIniPathAndFilename'])) {
                $useIniFile = php_ini_loaded_file();
            } else {
                $useIniFile = $settings['core']['subRequestPhpIniPathAndFilename'];
            }
            $command .= ' -c ' . escapeshellarg($useIniFile);
        }
        return $command;
    }

Usage Example

 /**
  * Run a standalone development server
  *
  * Starts an embedded server, see http://php.net/manual/en/features.commandline.webserver.php
  * Note: This requires PHP 5.4+
  *
  * To change the context Flow will run in, you can set the <b>FLOW_CONTEXT</b> environment variable:
  * <i>export FLOW_CONTEXT=Development && ./flow server:run</i>
  *
  * @param string $host The host name or IP address for the server to listen on
  * @param integer $port The server port to listen on
  * @return void
  */
 public function runCommand($host = '127.0.0.1', $port = 8081)
 {
     $command = Scripts::buildPhpCommand($this->settings);
     $address = sprintf('%s:%s', $host, $port);
     $command .= ' -S ' . escapeshellarg($address) . ' -t ' . escapeshellarg(FLOW_PATH_WEB) . ' ' . escapeshellarg(FLOW_PATH_FLOW . '/Scripts/PhpDevelopmentServerRouter.php');
     $this->outputLine('Server running. Please go to <b>http://' . $address . '</b> to browse the application.');
     exec($command);
 }