setDescription('Test defined proxy configuration!') ->addOption('url', '', InputOption::VALUE_REQUIRED, 'Url to reach on test') ; } protected function doExecute(InputInterface $input, OutputInterface $output) { $urlTest = $input->getOption('url'); if ($urlTest == null) { $urlTest = 'www.google.fr'; } $proxyConfig = new NetworkProxiesConfiguration($this->container['conf']); $clientOptions = []; // test http-proxy if ($proxyConfig->getHttpProxyConfiguration() != null) { $httpProxy = $proxyConfig->getHttpProxyConfiguration(); $clientOptions = array_merge($clientOptions, ['proxy' => $httpProxy]); $client = new Client($clientOptions); try { $response = $client->get($urlTest); $output->writeln("Test outgoing connection with proxy " . $httpProxy ." success with status code : " . $response->getStatusCode() . " "); } catch(\Exception $e) { $output->writeln("Outgoing connection error with proxy " . $httpProxy . " , " . $e->getMessage() . ""); } } // TODO: add test for ftp and socket proxy return 0; } }