-
-
Notifications
You must be signed in to change notification settings - Fork 67
/
drupal-check
executable file
·61 lines (53 loc) · 1.77 KB
/
drupal-check
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env php
<?php
if (PHP_VERSION_ID < 70100) {
printf("This tool requires at least PHP 7.1. You currently have %s installed. Please upgrade your PHP version.\n", PHP_VERSION);
exit(1);
}
use Composer\XdebugHandler\XdebugHandler;
gc_disable();
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
require __DIR__ . '/vendor/autoload.php';
} elseif (is_file(__DIR__ . '/../../autoload.php')) {
require_once __DIR__ . '/../../autoload.php';
}
else {
echo "Composer autoload file not found.\n";
echo "You need to run 'composer install'.\n";
exit(1);
}
$xdebug = new XdebugHandler('cua');
$xdebug->check();
unset($xdebug);
// Bump memory limit
// @see https://github.com/composer/composer/blob/master/bin/composer#L21
if (function_exists('ini_set')) {
@ini_set('display_errors', 1);
$memoryInBytes = function ($value) {
$unit = strtolower(substr($value, -1, 1));
$value = (int) $value;
switch($unit) {
case 'g':
$value *= 1024;
// no break (cumulative multiplier)
case 'm':
$value *= 1024;
// no break (cumulative multiplier)
case 'k':
$value *= 1024;
}
return $value;
};
$memoryLimit = trim(ini_get('memory_limit'));
// Increase memory_limit if it is lower than 1.5GB
if ($memoryLimit != -1 && $memoryInBytes($memoryLimit) < 1024 * 1024 * 1536) {
@ini_set('memory_limit', '1536M');
}
// Set user defined memory limit
if ($memoryLimit = getenv('COMPOSER_MEMORY_LIMIT')) {
@ini_set('memory_limit', $memoryLimit);
}
unset($memoryInBytes, $memoryLimit);
}
putenv('DRUPAL_CHECK_BINARY='.realpath($_SERVER['argv'][0]));
(new \DrupalCheck\Application())->run();