composer 1.1 KB

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