-
Notifications
You must be signed in to change notification settings - Fork 21
/
install.php
63 lines (54 loc) · 1.65 KB
/
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
56
57
58
59
60
61
62
63
<?php
/**
* Part of CodeIgniter Cli
*
* @author Kenji Suzuki <https://github.com/kenjis>
* @license MIT License
* @copyright 2015 Kenji Suzuki
* @link https://github.com/kenjis/codeigniter-cli
*/
$installer = new Installer();
$installer->install();
class Installer
{
public static function install()
{
self::recursiveCopy('vendor/kenjis/codeigniter-cli/config', 'config');
@mkdir('tmp', 0755);
@mkdir('tmp/log', 0755);
self::copy('vendor/kenjis/codeigniter-cli/cli', 'cli');
self::copy('vendor/kenjis/codeigniter-cli/ci_instance.php', 'ci_instance.php');
chmod('cli', 0755);
}
private static function copy($src, $dst)
{
$success = copy($src, $dst);
if ($success) {
echo 'copied: ' . $dst . PHP_EOL;
}
}
/**
* Recursive Copy
*
* @param string $src
* @param string $dst
*/
private static function recursiveCopy($src, $dst)
{
@mkdir($dst, 0755);
$iterator = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($src, \RecursiveDirectoryIterator::SKIP_DOTS),
\RecursiveIteratorIterator::SELF_FIRST
);
foreach ($iterator as $file) {
if ($file->isDir()) {
@mkdir($dst . '/' . $iterator->getSubPathName());
} else {
$success = copy($file, $dst . '/' . $iterator->getSubPathName());
if ($success) {
echo 'copied: ' . $dst . '/' . $iterator->getSubPathName() . PHP_EOL;
}
}
}
}
}