-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathinstall.php
More file actions
73 lines (62 loc) · 2.02 KB
/
Copy pathinstall.php
File metadata and controls
73 lines (62 loc) · 2.02 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
<?php
/**
* This script mostly just replaces a bunch of placeholders
* inside of the project to kick-start a VISU project.
*/
/**
* Helpers
* ----------------------------------------------------------------------------
*/
enum CLIColor : string {
case RED = "\033[31m";
case GREEN = "\033[32m";
case YELLOW = "\033[33m";
case BLUE = "\033[34m";
case MAGENTA = "\033[35m";
case CYAN = "\033[36m";
case WHITE = "\033[37m";
case RESET = "\033[0m";
}
function printLine($line, $indent = 0, ?CLIColor $color = null) {
$indent = str_repeat(' ', $indent);
// split by lines
$lines = explode(PHP_EOL, $line);
foreach ($lines as $line) {
echo $indent . ($color ? $color->value : '') . $line . CLIColor::RESET->value . PHP_EOL;
}
}
function printSeperator(string $char = '-', int $length = 80) {
printLine(str_repeat($char, $length));
}
/**
* Install Setup
* ----------------------------------------------------------------------------
*/
printSeperator();
printLine('VISU Project Setup', 2, CLIColor::CYAN);
printSeperator();
/**
* Check for requirements
* ----------------------------------------------------------------------------
*/
// Check for PHP version > 8.1
if (version_compare(PHP_VERSION, '8.1.0') < 0) {
printLine('Your PHP version is ' . PHP_VERSION . ' but VISU requires at least PHP 8.1.0', 0, CLIColor::RED);
exit(1);
}
// check if the "glfw" extension is installed
if (!extension_loaded('glfw')) {
printLine('The "glfw" extension is not installed.', 0, CLIColor::RED);
printLine('Please goto https://phpgl.net and follow the installation instructions.', 0, CLIColor::RED);
exit(1);
}
/**
* Ask for setup values
* ----------------------------------------------------------------------------
*/
$projectName = '';
printLine('# Please enter the project name:', 0, CLIColor::YELLOW);
while (empty($projectName)) {
$projectName = readline('Project Name: ');
}
printLine('Great! Your project will be named "' . $projectName . '".', 0, CLIColor::GREEN);