composer 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. #!/usr/bin/env php
  2. <?php
  3. if (PHP_SAPI !== 'cli') {
  4. echo 'Warning: Composer should be invoked via the CLI version of PHP, not the '.PHP_SAPI.' SAPI'.PHP_EOL;
  5. }
  6. require __DIR__.'/../src/bootstrap.php';
  7. use Composer\Factory;
  8. use Composer\XdebugHandler;
  9. use Composer\Console\Application;
  10. error_reporting(-1);
  11. // Create output for XdebugHandler and Application
  12. $output = Factory::createOutput();
  13. $xdebug = new XdebugHandler($output);
  14. $xdebug->check();
  15. unset($xdebug);
  16. if (function_exists('ini_set')) {
  17. @ini_set('display_errors', 1);
  18. $memoryInBytes = function ($value) {
  19. $unit = strtolower(substr($value, -1, 1));
  20. $value = (int) $value;
  21. switch($unit) {
  22. case 'g':
  23. $value *= 1024;
  24. // no break (cumulative multiplier)
  25. case 'm':
  26. $value *= 1024;
  27. // no break (cumulative multiplier)
  28. case 'k':
  29. $value *= 1024;
  30. }
  31. return $value;
  32. };
  33. $memoryLimit = trim(ini_get('memory_limit'));
  34. // Increase memory_limit if it is lower than 1.5GB
  35. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
  36. @ini_set('memory_limit', '1536M');
  37. }
  38. unset($memoryInBytes, $memoryLimit);
  39. }
  40. // run the command application
  41. $application = new Application();
  42. $application->run(null, $output);