composer 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\XdebugHandler;
  8. use Composer\Console\Application;
  9. error_reporting(-1);
  10. $xdebug = new XdebugHandler($argv);
  11. $xdebug->check();
  12. unset($xdebug);
  13. if (function_exists('ini_set')) {
  14. @ini_set('display_errors', 1);
  15. $memoryInBytes = function ($value) {
  16. $unit = strtolower(substr($value, -1, 1));
  17. $value = (int) $value;
  18. switch($unit) {
  19. case 'g':
  20. $value *= 1024;
  21. // no break (cumulative multiplier)
  22. case 'm':
  23. $value *= 1024;
  24. // no break (cumulative multiplier)
  25. case 'k':
  26. $value *= 1024;
  27. }
  28. return $value;
  29. };
  30. $memoryLimit = trim(ini_get('memory_limit'));
  31. // Increase memory_limit if it is lower than 1GB
  32. if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1024) {
  33. @ini_set('memory_limit', '1G');
  34. }
  35. unset($memoryInBytes, $memoryLimit);
  36. }
  37. // run the command application
  38. $application = new Application();
  39. $application->run();