DiagnoseCommand.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  1. <?php
  2. /*
  3. * This file is part of Composer.
  4. *
  5. * (c) Nils Adermann <naderman@naderman.de>
  6. * Jordi Boggiano <j.boggiano@seld.be>
  7. *
  8. * For the full copyright and license information, please view the LICENSE
  9. * file that was distributed with this source code.
  10. */
  11. namespace Composer\Command;
  12. use Composer\Composer;
  13. use Composer\Factory;
  14. use Composer\Config;
  15. use Composer\Downloader\TransportException;
  16. use Composer\Plugin\CommandEvent;
  17. use Composer\Plugin\PluginEvents;
  18. use Composer\Util\ConfigValidator;
  19. use Composer\Util\ProcessExecutor;
  20. use Composer\Util\RemoteFilesystem;
  21. use Composer\Util\StreamContextFactory;
  22. use Composer\SelfUpdate\Keys;
  23. use Composer\SelfUpdate\Versions;
  24. use Composer\IO\NullIO;
  25. use Symfony\Component\Console\Input\InputInterface;
  26. use Symfony\Component\Console\Output\OutputInterface;
  27. /**
  28. * @author Jordi Boggiano <j.boggiano@seld.be>
  29. */
  30. class DiagnoseCommand extends BaseCommand
  31. {
  32. /** @var RemoteFileSystem */
  33. protected $rfs;
  34. /** @var ProcessExecutor */
  35. protected $process;
  36. /** @var int */
  37. protected $exitCode = 0;
  38. protected function configure()
  39. {
  40. $this
  41. ->setName('diagnose')
  42. ->setDescription('Diagnoses the system to identify common errors.')
  43. ->setHelp(<<<EOT
  44. The <info>diagnose</info> command checks common errors to help debugging problems.
  45. The process exit code will be 1 in case of warnings and 2 for errors.
  46. EOT
  47. )
  48. ;
  49. }
  50. /**
  51. * {@inheritdoc}
  52. */
  53. protected function execute(InputInterface $input, OutputInterface $output)
  54. {
  55. $composer = $this->getComposer(false);
  56. $io = $this->getIO();
  57. if ($composer) {
  58. $commandEvent = new CommandEvent(PluginEvents::COMMAND, 'diagnose', $input, $output);
  59. $composer->getEventDispatcher()->dispatch($commandEvent->getName(), $commandEvent);
  60. $io->write('Checking composer.json: ', false);
  61. $this->outputResult($this->checkComposerSchema());
  62. }
  63. if ($composer) {
  64. $config = $composer->getConfig();
  65. } else {
  66. $config = Factory::createConfig();
  67. }
  68. $config->merge(array('config' => array('secure-http' => false)));
  69. $config->prohibitUrlByConfig('http://packagist.org', new NullIO);
  70. $this->rfs = Factory::createRemoteFilesystem($io, $config);
  71. $this->process = new ProcessExecutor($io);
  72. $io->write('Checking platform settings: ', false);
  73. $this->outputResult($this->checkPlatform());
  74. $io->write('Checking git settings: ', false);
  75. $this->outputResult($this->checkGit());
  76. $io->write('Checking http connectivity to packagist: ', false);
  77. $this->outputResult($this->checkHttp('http', $config));
  78. $io->write('Checking https connectivity to packagist: ', false);
  79. $this->outputResult($this->checkHttp('https', $config));
  80. $opts = stream_context_get_options(StreamContextFactory::getContext('http://example.org'));
  81. if (!empty($opts['http']['proxy'])) {
  82. $io->write('Checking HTTP proxy: ', false);
  83. $this->outputResult($this->checkHttpProxy());
  84. $io->write('Checking HTTP proxy support for request_fulluri: ', false);
  85. $this->outputResult($this->checkHttpProxyFullUriRequestParam());
  86. $io->write('Checking HTTPS proxy support for request_fulluri: ', false);
  87. $this->outputResult($this->checkHttpsProxyFullUriRequestParam());
  88. }
  89. if ($oauth = $config->get('github-oauth')) {
  90. foreach ($oauth as $domain => $token) {
  91. $io->write('Checking '.$domain.' oauth access: ', false);
  92. $this->outputResult($this->checkGithubOauth($domain, $token));
  93. }
  94. } else {
  95. $io->write('Checking github.com rate limit: ', false);
  96. try {
  97. $rate = $this->getGithubRateLimit('github.com');
  98. $this->outputResult(true);
  99. if (10 > $rate['remaining']) {
  100. $io->write('<warning>WARNING</warning>');
  101. $io->write(sprintf(
  102. '<comment>Github has a rate limit on their API. '
  103. . 'You currently have <options=bold>%u</options=bold> '
  104. . 'out of <options=bold>%u</options=bold> requests left.' . PHP_EOL
  105. . 'See https://developer.github.com/v3/#rate-limiting and also' . PHP_EOL
  106. . ' https://getcomposer.org/doc/articles/troubleshooting.md#api-rate-limit-and-oauth-tokens</comment>',
  107. $rate['remaining'],
  108. $rate['limit']
  109. ));
  110. }
  111. } catch (\Exception $e) {
  112. if ($e instanceof TransportException && $e->getCode() === 401) {
  113. $this->outputResult('<comment>The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it</comment>');
  114. } else {
  115. $this->outputResult($e);
  116. }
  117. }
  118. }
  119. $io->write('Checking disk free space: ', false);
  120. $this->outputResult($this->checkDiskSpace($config));
  121. if ('phar:' === substr(__FILE__, 0, 5)) {
  122. $io->write('Checking pubkeys: ', false);
  123. $this->outputResult($this->checkPubKeys($config));
  124. $io->write('Checking composer version: ', false);
  125. $this->outputResult($this->checkVersion($config));
  126. }
  127. return $this->exitCode;
  128. }
  129. private function checkComposerSchema()
  130. {
  131. $validator = new ConfigValidator($this->getIO());
  132. list($errors, , $warnings) = $validator->validate(Factory::getComposerFile());
  133. if ($errors || $warnings) {
  134. $messages = array(
  135. 'error' => $errors,
  136. 'warning' => $warnings,
  137. );
  138. $output = '';
  139. foreach ($messages as $style => $msgs) {
  140. foreach ($msgs as $msg) {
  141. $output .= '<' . $style . '>' . $msg . '</' . $style . '>' . PHP_EOL;
  142. }
  143. }
  144. return rtrim($output);
  145. }
  146. return true;
  147. }
  148. private function checkGit()
  149. {
  150. $this->process->execute('git config color.ui', $output);
  151. if (strtolower(trim($output)) === 'always') {
  152. return '<comment>Your git color.ui setting is set to always, this is known to create issues. Use "git config --global color.ui true" to set it correctly.</comment>';
  153. }
  154. return true;
  155. }
  156. private function checkHttp($proto, Config $config)
  157. {
  158. $disableTls = false;
  159. $result = array();
  160. if ($proto === 'https' && $config->get('disable-tls') === true) {
  161. $disableTls = true;
  162. $result[] = '<warning>Composer is configured to disable SSL/TLS protection. This will leave remote HTTPS requests vulnerable to Man-In-The-Middle attacks.</warning>';
  163. }
  164. if ($proto === 'https' && !extension_loaded('openssl') && !$disableTls) {
  165. $result[] = '<error>Composer is configured to use SSL/TLS protection but the openssl extension is not available.</error>';
  166. }
  167. try {
  168. $this->rfs->getContents('packagist.org', $proto . '://packagist.org/packages.json', false);
  169. } catch (TransportException $e) {
  170. if (false !== strpos($e->getMessage(), 'cafile')) {
  171. $result[] = '<error>[' . get_class($e) . '] ' . $e->getMessage() . '</error>';
  172. $result[] = '<error>Unable to locate a valid CA certificate file. You must set a valid \'cafile\' option.</error>';
  173. $result[] = '<error>You can alternatively disable this error, at your own risk, by enabling the \'disable-tls\' option.</error>';
  174. } else {
  175. array_unshift($result, '[' . get_class($e) . '] ' . $e->getMessage());
  176. }
  177. }
  178. if (count($result) > 0) {
  179. return $result;
  180. }
  181. return true;
  182. }
  183. private function checkHttpProxy()
  184. {
  185. $protocol = extension_loaded('openssl') ? 'https' : 'http';
  186. try {
  187. $json = json_decode($this->rfs->getContents('packagist.org', $protocol . '://packagist.org/packages.json', false), true);
  188. $hash = reset($json['provider-includes']);
  189. $hash = $hash['sha256'];
  190. $path = str_replace('%hash%', $hash, key($json['provider-includes']));
  191. $provider = $this->rfs->getContents('packagist.org', $protocol . '://packagist.org/'.$path, false);
  192. if (hash('sha256', $provider) !== $hash) {
  193. return 'It seems that your proxy is modifying http traffic on the fly';
  194. }
  195. } catch (\Exception $e) {
  196. return $e;
  197. }
  198. return true;
  199. }
  200. /**
  201. * Due to various proxy servers configurations, some servers can't handle non-standard HTTP "http_proxy_request_fulluri" parameter,
  202. * and will return error 500/501 (as not implemented), see discussion @ https://github.com/composer/composer/pull/1825.
  203. * This method will test, if you need to disable this parameter via setting extra environment variable in your system.
  204. *
  205. * @return bool|string
  206. */
  207. private function checkHttpProxyFullUriRequestParam()
  208. {
  209. $url = 'http://packagist.org/packages.json';
  210. try {
  211. $this->rfs->getContents('packagist.org', $url, false);
  212. } catch (TransportException $e) {
  213. try {
  214. $this->rfs->getContents('packagist.org', $url, false, array('http' => array('request_fulluri' => false)));
  215. } catch (TransportException $e) {
  216. return 'Unable to assess the situation, maybe packagist.org is down ('.$e->getMessage().')';
  217. }
  218. return 'It seems there is a problem with your proxy server, try setting the "HTTP_PROXY_REQUEST_FULLURI" and "HTTPS_PROXY_REQUEST_FULLURI" environment variables to "false"';
  219. }
  220. return true;
  221. }
  222. /**
  223. * Due to various proxy servers configurations, some servers can't handle non-standard HTTP "http_proxy_request_fulluri" parameter,
  224. * and will return error 500/501 (as not implemented), see discussion @ https://github.com/composer/composer/pull/1825.
  225. * This method will test, if you need to disable this parameter via setting extra environment variable in your system.
  226. *
  227. * @return bool|string
  228. */
  229. private function checkHttpsProxyFullUriRequestParam()
  230. {
  231. if (!extension_loaded('openssl')) {
  232. return 'You need the openssl extension installed for this check';
  233. }
  234. $url = 'https://api.github.com/repos/Seldaek/jsonlint/zipball/1.0.0';
  235. try {
  236. $this->rfs->getContents('github.com', $url, false);
  237. } catch (TransportException $e) {
  238. try {
  239. $this->rfs->getContents('github.com', $url, false, array('http' => array('request_fulluri' => false)));
  240. } catch (TransportException $e) {
  241. return 'Unable to assess the situation, maybe github is down ('.$e->getMessage().')';
  242. }
  243. return 'It seems there is a problem with your proxy server, try setting the "HTTPS_PROXY_REQUEST_FULLURI" environment variable to "false"';
  244. }
  245. return true;
  246. }
  247. private function checkGithubOauth($domain, $token)
  248. {
  249. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  250. try {
  251. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/' : 'https://'.$domain.'/api/v3/';
  252. return $this->rfs->getContents($domain, $url, false, array(
  253. 'retry-auth-failure' => false,
  254. )) ? true : 'Unexpected error';
  255. } catch (\Exception $e) {
  256. if ($e instanceof TransportException && $e->getCode() === 401) {
  257. return '<comment>The oauth token for '.$domain.' seems invalid, run "composer config --global --unset github-oauth.'.$domain.'" to remove it</comment>';
  258. }
  259. return $e;
  260. }
  261. }
  262. /**
  263. * @param string $domain
  264. * @param string $token
  265. * @throws TransportException
  266. * @return array
  267. */
  268. private function getGithubRateLimit($domain, $token = null)
  269. {
  270. if ($token) {
  271. $this->getIO()->setAuthentication($domain, $token, 'x-oauth-basic');
  272. }
  273. $url = $domain === 'github.com' ? 'https://api.'.$domain.'/rate_limit' : 'https://'.$domain.'/api/rate_limit';
  274. $json = $this->rfs->getContents($domain, $url, false, array('retry-auth-failure' => false));
  275. $data = json_decode($json, true);
  276. return $data['resources']['core'];
  277. }
  278. private function checkDiskSpace($config)
  279. {
  280. $minSpaceFree = 1024 * 1024;
  281. if ((($df = @disk_free_space($dir = $config->get('home'))) !== false && $df < $minSpaceFree)
  282. || (($df = @disk_free_space($dir = $config->get('vendor-dir'))) !== false && $df < $minSpaceFree)
  283. ) {
  284. return '<error>The disk hosting '.$dir.' is full</error>';
  285. }
  286. return true;
  287. }
  288. private function checkPubKeys($config)
  289. {
  290. $home = $config->get('home');
  291. $errors = array();
  292. $io = $this->getIO();
  293. if (file_exists($home.'/keys.tags.pub') && file_exists($home.'/keys.dev.pub')) {
  294. $io->write('');
  295. }
  296. if (file_exists($home.'/keys.tags.pub')) {
  297. $io->write('Tags Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.tags.pub'));
  298. } else {
  299. $errors[] = '<error>Missing pubkey for tags verification</error>';
  300. }
  301. if (file_exists($home.'/keys.dev.pub')) {
  302. $io->write('Dev Public Key Fingerprint: ' . Keys::fingerprint($home.'/keys.dev.pub'));
  303. } else {
  304. $errors[] = '<error>Missing pubkey for dev verification</error>';
  305. }
  306. if ($errors) {
  307. $errors[] = '<error>Run composer self-update --update-keys to set them up</error>';
  308. }
  309. return $errors ?: true;
  310. }
  311. private function checkVersion($config)
  312. {
  313. $versionsUtil = new Versions($config, $this->rfs);
  314. $latest = $versionsUtil->getLatest();
  315. if (Composer::VERSION !== $latest['version'] && Composer::VERSION !== '@package_version@') {
  316. return '<comment>You are not running the latest '.$versionsUtil->getChannel().' version, run `composer self-update` to update ('.Composer::VERSION.' => '.$latest['version'].')</comment>';
  317. }
  318. return true;
  319. }
  320. /**
  321. * @param bool|string|\Exception $result
  322. */
  323. private function outputResult($result)
  324. {
  325. $io = $this->getIO();
  326. if (true === $result) {
  327. $io->write('<info>OK</info>');
  328. return;
  329. }
  330. $hadError = false;
  331. if ($result instanceof \Exception) {
  332. $result = '<error>['.get_class($result).'] '.$result->getMessage().'</error>';
  333. }
  334. if (!$result) {
  335. // falsey results should be considered as an error, even if there is nothing to output
  336. $hadError = true;
  337. } else {
  338. if (!is_array($result)) {
  339. $result = array($result);
  340. }
  341. foreach ($result as $message) {
  342. if (false !== strpos($message, '<error>')) {
  343. $hadError = true;
  344. }
  345. }
  346. }
  347. if ($hadError) {
  348. $io->write('<error>FAIL</error>');
  349. $this->exitCode = 2;
  350. } else {
  351. $io->write('<warning>WARNING</warning>');
  352. $this->exitCode = 1;
  353. }
  354. if ($result) {
  355. foreach ($result as $message) {
  356. $io->write($message);
  357. }
  358. }
  359. }
  360. private function checkPlatform()
  361. {
  362. $output = '';
  363. $out = function ($msg, $style) use (&$output) {
  364. $output .= '<'.$style.'>'.$msg.'</'.$style.'>'.PHP_EOL;
  365. };
  366. // code below taken from getcomposer.org/installer, any changes should be made there and replicated here
  367. $errors = array();
  368. $warnings = array();
  369. $iniPath = php_ini_loaded_file();
  370. $displayIniMessage = false;
  371. if ($iniPath) {
  372. $iniMessage = PHP_EOL.PHP_EOL.'The php.ini used by your command-line PHP is: ' . $iniPath;
  373. } else {
  374. $iniMessage = PHP_EOL.PHP_EOL.'A php.ini file does not exist. You will have to create one.';
  375. }
  376. $iniMessage .= PHP_EOL.'If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.';
  377. if (!function_exists('json_decode')) {
  378. $errors['json'] = true;
  379. }
  380. if (!extension_loaded('Phar')) {
  381. $errors['phar'] = true;
  382. }
  383. if (!extension_loaded('filter')) {
  384. $errors['filter'] = true;
  385. }
  386. if (!extension_loaded('hash')) {
  387. $errors['hash'] = true;
  388. }
  389. if (!extension_loaded('iconv') && !extension_loaded('mbstring')) {
  390. $errors['iconv_mbstring'] = true;
  391. }
  392. if (!ini_get('allow_url_fopen')) {
  393. $errors['allow_url_fopen'] = true;
  394. }
  395. if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) {
  396. $errors['ioncube'] = ioncube_loader_version();
  397. }
  398. if (PHP_VERSION_ID < 50302) {
  399. $errors['php'] = PHP_VERSION;
  400. }
  401. if (!isset($errors['php']) && PHP_VERSION_ID < 50304) {
  402. $warnings['php'] = PHP_VERSION;
  403. }
  404. if (!extension_loaded('openssl')) {
  405. $errors['openssl'] = true;
  406. }
  407. if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) {
  408. $warnings['openssl_version'] = true;
  409. }
  410. if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && ini_get('apc.enable_cli')) {
  411. $warnings['apc_cli'] = true;
  412. }
  413. ob_start();
  414. phpinfo(INFO_GENERAL);
  415. $phpinfo = ob_get_clean();
  416. if (preg_match('{Configure Command(?: *</td><td class="v">| *=> *)(.*?)(?:</td>|$)}m', $phpinfo, $match)) {
  417. $configure = $match[1];
  418. if (false !== strpos($configure, '--enable-sigchild')) {
  419. $warnings['sigchild'] = true;
  420. }
  421. if (false !== strpos($configure, '--with-curlwrappers')) {
  422. $warnings['curlwrappers'] = true;
  423. }
  424. }
  425. if (ini_get('xdebug.profiler_enabled')) {
  426. $warnings['xdebug_profile'] = true;
  427. } elseif (extension_loaded('xdebug')) {
  428. $warnings['xdebug_loaded'] = true;
  429. }
  430. if (!empty($errors)) {
  431. foreach ($errors as $error => $current) {
  432. switch ($error) {
  433. case 'json':
  434. $text = PHP_EOL."The json extension is missing.".PHP_EOL;
  435. $text .= "Install it or recompile php without --disable-json";
  436. break;
  437. case 'phar':
  438. $text = PHP_EOL."The phar extension is missing.".PHP_EOL;
  439. $text .= "Install it or recompile php without --disable-phar";
  440. break;
  441. case 'filter':
  442. $text = PHP_EOL."The filter extension is missing.".PHP_EOL;
  443. $text .= "Install it or recompile php without --disable-filter";
  444. break;
  445. case 'hash':
  446. $text = PHP_EOL."The hash extension is missing.".PHP_EOL;
  447. $text .= "Install it or recompile php without --disable-hash";
  448. break;
  449. case 'iconv_mbstring':
  450. $text = PHP_EOL."The iconv OR mbstring extension is required and both are missing.".PHP_EOL;
  451. $text .= "Install either of them or recompile php without --disable-iconv";
  452. break;
  453. case 'unicode':
  454. $text = PHP_EOL."The detect_unicode setting must be disabled.".PHP_EOL;
  455. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  456. $text .= " detect_unicode = Off";
  457. $displayIniMessage = true;
  458. break;
  459. case 'suhosin':
  460. $text = PHP_EOL."The suhosin.executor.include.whitelist setting is incorrect.".PHP_EOL;
  461. $text .= "Add the following to the end of your `php.ini` or suhosin.ini (Example path [for Debian]: /etc/php5/cli/conf.d/suhosin.ini):".PHP_EOL;
  462. $text .= " suhosin.executor.include.whitelist = phar ".$current;
  463. $displayIniMessage = true;
  464. break;
  465. case 'php':
  466. $text = PHP_EOL."Your PHP ({$current}) is too old, you must upgrade to PHP 5.3.2 or higher.";
  467. break;
  468. case 'allow_url_fopen':
  469. $text = PHP_EOL."The allow_url_fopen setting is incorrect.".PHP_EOL;
  470. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  471. $text .= " allow_url_fopen = On";
  472. $displayIniMessage = true;
  473. break;
  474. case 'ioncube':
  475. $text = PHP_EOL."Your ionCube Loader extension ($current) is incompatible with Phar files.".PHP_EOL;
  476. $text .= "Upgrade to ionCube 4.0.9 or higher or remove this line (path may be different) from your `php.ini` to disable it:".PHP_EOL;
  477. $text .= " zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so";
  478. $displayIniMessage = true;
  479. break;
  480. case 'openssl':
  481. $text = PHP_EOL."The openssl extension is missing, which means that secure HTTPS transfers are impossible.".PHP_EOL;
  482. $text .= "If possible you should enable it or recompile php with --with-openssl";
  483. break;
  484. }
  485. $out($text, 'error');
  486. }
  487. $output .= PHP_EOL;
  488. }
  489. if (!empty($warnings)) {
  490. foreach ($warnings as $warning => $current) {
  491. switch ($warning) {
  492. case 'apc_cli':
  493. $text = "The apc.enable_cli setting is incorrect.".PHP_EOL;
  494. $text .= "Add the following to the end of your `php.ini`:".PHP_EOL;
  495. $text .= " apc.enable_cli = Off";
  496. $displayIniMessage = true;
  497. break;
  498. case 'sigchild':
  499. $text = "PHP was compiled with --enable-sigchild which can cause issues on some platforms.".PHP_EOL;
  500. $text .= "Recompile it without this flag if possible, see also:".PHP_EOL;
  501. $text .= " https://bugs.php.net/bug.php?id=22999";
  502. break;
  503. case 'curlwrappers':
  504. $text = "PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.".PHP_EOL;
  505. $text .= " Recompile it without this flag if possible";
  506. break;
  507. case 'php':
  508. $text = "Your PHP ({$current}) is quite old, upgrading to PHP 5.3.4 or higher is recommended.".PHP_EOL;
  509. $text .= " Composer works with 5.3.2+ for most people, but there might be edge case issues.";
  510. break;
  511. case 'openssl_version':
  512. // Attempt to parse version number out, fallback to whole string value.
  513. $opensslVersion = strstr(trim(strstr(OPENSSL_VERSION_TEXT, ' ')), ' ', true);
  514. $opensslVersion = $opensslVersion ?: OPENSSL_VERSION_TEXT;
  515. $text = "The OpenSSL library ({$opensslVersion}) used by PHP does not support TLSv1.2 or TLSv1.1.".PHP_EOL;
  516. $text .= "If possible you should upgrade OpenSSL to version 1.0.1 or above.";
  517. break;
  518. case 'xdebug_loaded':
  519. $text = "The xdebug extension is loaded, this can slow down Composer a little.".PHP_EOL;
  520. $text .= " Disabling it when using Composer is recommended.";
  521. break;
  522. case 'xdebug_profile':
  523. $text = "The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.".PHP_EOL;
  524. $text .= "Add the following to the end of your `php.ini` to disable it:".PHP_EOL;
  525. $text .= " xdebug.profiler_enabled = 0";
  526. $displayIniMessage = true;
  527. break;
  528. }
  529. $out($text, 'comment');
  530. }
  531. }
  532. if ($displayIniMessage) {
  533. $out($iniMessage, 'comment');
  534. }
  535. return !$warnings && !$errors ? true : $output;
  536. }
  537. }