-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.php
More file actions
executable file
·44 lines (33 loc) · 1.06 KB
/
install.php
File metadata and controls
executable file
·44 lines (33 loc) · 1.06 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
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
function get_install_dir($current_dir) {
global $argv;
if (count($argv) < 2) {
die("Usage: php install.php <phpdoc-dir>\n");
}
$install_dir = realpath($argv[1]);
if (!is_dir($install_dir) || !is_writable($install_dir)) {
die("Installation dir should be writable!\n");
}
if ($current_dir === $install_dir) {
die("Installation dir should not be the same as current dir!\n");
}
return $install_dir;
}
$current_dir = realpath(dirname(__FILE__));
$install_dir = get_install_dir($current_dir);
$file_iterator = new RecursiveIteratorIterator(
new RecursiveRegexIterator(
new RecursiveDirectoryIterator($current_dir, RecursiveDirectoryIterator::SKIP_DOTS),
'/^((?!\.git|.idea|README).)+$/'
)
);
foreach($file_iterator as $key => $item) {
$destination = str_replace($current_dir, $install_dir, $item->getRealpath());
echo "Creating symlink: ", $item->getRealpath(), " => " , $destination, PHP_EOL;
if (is_link($destination)) {
unlink($destination);
}
symlink($item->getRealpath(), $destination);
}