-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.php
42 lines (34 loc) · 875 Bytes
/
index.php
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
<?php
const PHPUP_VERSION = '0.2.0';
if (!isset($argv[1])) {
echo "Not enough arguments \n";
exit(1);
}
// @TODO Handle restart
putenv("COMPOSER_ALLOW_XDEBUG=1");
putenv("PHPSTAN_ALLOW_XDEBUG=1");
putenv("RECTOR_ALLOW_XDEBUG=1");
$command = escapeshellcmd($argv[1]);
$vendorBinPath = __DIR__ . '/vendor/bin/';
if ('list' === $command) {
$files = scandir($vendorBinPath);
foreach ($files as $file) {
if ($file === '.' || $file === '..') { continue; }
echo $file . "\n";
}
exit;
}
if ('--version' === $command) {
echo 'phpup v', PHPUP_VERSION, ', with PHP v', PHP_VERSION, "\n";
exit;
}
array_shift($_SERVER['argv']);
$pathToBinary = $vendorBinPath . $command;
if (file_exists($pathToBinary)) {
require_once $pathToBinary;
exit;
} else if (file_exists($command)) {
require_once $command;
exit;
}
exit(1);