-
Notifications
You must be signed in to change notification settings - Fork 38
/
auto-install.php
55 lines (48 loc) · 1.48 KB
/
auto-install.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
43
44
45
46
47
48
49
50
51
52
53
54
55
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Baun Auto Installer</title>
<link rel="stylesheet" href="/auto-install.css">
</head>
<body>
<?php
echo 'Baun Auto Installer<br>';
echo '-------------------<br><br>';
try {
$output = [];
if (!file_exists(BASE_PATH . 'composer.phar')) {
echo 'Attempting to download composer...<br>';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://getcomposer.org/installer');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
$error = curl_error($ch);
curl_close($ch);
if ($data === false) {
die($error);
}
file_put_contents(BASE_PATH . 'composer.phar', $data);
echo 'Attempting to install composer...<br>';
$result = shell_exec('cd ' . escapeshellcmd(BASE_PATH) . ' && php composer.phar install');
$output = array_merge($output, explode("\n", $result));
}
echo 'Attempting to install composer packages...<br>';
$result = shell_exec('cd ' . escapeshellcmd(BASE_PATH) . ' && php composer.phar update');
$output = array_merge($output, explode("\n", $result));
echo '<ul>';
if (!empty($output)) {
foreach ($output as $item) {
if ($item) {
echo '<li>' . $item . '</li>';
}
}
}
echo '</ul><br>';
echo '<a href="/">Finished installing. Lets go →</a><br>';
} catch(Exception $e) {
echo '<span class="error">Auto install failed (missing vendor/autoload.php). Run <code>composer install</code> manually.</span>';
}
?>
</body>
</html>