PHPPM\Commands\ConfigTrait::loadConfig PHP Method

loadConfig() protected method

protected loadConfig ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output )
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
    protected function loadConfig(InputInterface $input, OutputInterface $output)
    {
        $config = [];
        if ($path = $this->getConfigPath()) {
            $content = file_get_contents($path);
            $config = json_decode($content, true);
        }
        $config['bridge'] = $this->optionOrConfigValue($input, 'bridge', $config);
        $config['host'] = $this->optionOrConfigValue($input, 'host', $config);
        $config['port'] = (int) $this->optionOrConfigValue($input, 'port', $config);
        $config['workers'] = (int) $this->optionOrConfigValue($input, 'workers', $config);
        $config['app-env'] = $this->optionOrConfigValue($input, 'app-env', $config);
        $config['debug'] = $this->optionOrConfigValue($input, 'debug', $config);
        $config['logging'] = $this->optionOrConfigValue($input, 'logging', $config);
        $config['static'] = (bool) $this->optionOrConfigValue($input, 'static', $config);
        $config['bootstrap'] = $this->optionOrConfigValue($input, 'bootstrap', $config);
        $config['max-requests'] = (int) $this->optionOrConfigValue($input, 'max-requests', $config);
        $config['concurrent-requests'] = (bool) $this->optionOrConfigValue($input, 'concurrent-requests', $config);
        $config['socket-path'] = $this->optionOrConfigValue($input, 'socket-path', $config);
        $config['cgi-path'] = $this->optionOrConfigValue($input, 'cgi-path', $config);
        if (false === $config['cgi-path']) {
            //not set in config nor in command options -> autodetect path
            $executableFinder = new PhpExecutableFinder();
            $binary = $executableFinder->find();
            $cgiPaths = [$binary . '-cgi', str_replace('php', 'php-cgi', $binary)];
            foreach ($cgiPaths as $cgiPath) {
                $path = trim(`which {$cgiPath}`);
                if ($path) {
                    $config['cgi-path'] = $path;
                    break;
                }
            }
            if (false === $config['cgi-path']) {
                $output->writeln('<error>PPM could find a php-cgi path. Please specify by --cgi-path=</error>');
                exit(1);
            }
        }
        return $config;
    }