generated from elapse-annals/laravel-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_win
76 lines (66 loc) · 1.54 KB
/
create_win
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
74
75
76
#!/usr/bin/env php
<?php
/**
* User: ben
* Email: benhuang1024@gmail.com
* Date: 2019-01-01
* Time: 00:01
*/
$filter_folder = [
'.git',
'vendor',
'node_modules',
'.github',
'.styleci.yml',
'.travis.yml',
];
$product = __DIR__.'/../'.checkRequestVariable();
$laravel_plus_patch = __DIR__;
dirCopy($laravel_plus_patch,$product);
function dirCopy($src = '', $dst = '')
{
global $filter_folder;
if (empty($src) || empty($dst))
{
return false;
}
$dir = opendir($src);
dirMkdir($dst);
while (false !== ($file = readdir($dir)))
{
if (($file != '.') && ($file != '..') && !in_array($file,$filter_folder))
{
echo $file.PHP_EOL;
if (is_dir($src . '/' . $file))
{
dirCopy($src . '/' . $file, $dst . '/' . $file);
}
else
{
copy($src . '/' . $file, $dst . '/' . $file);
}
}
}
closedir($dir);
return true;
}
function dirMkdir($path = '', $mode = 0777, $recursive = true)
{
clearstatcache();
if (!is_dir($path))
{
mkdir($path, $mode, $recursive);
return chmod($path, $mode);
}
return true;
}
function checkRequestVariable(): string
{
global $argv, $laravel_plus_basename;
if (empty($argv) || !isset($argv[1]) || empty($argv[1])) {
echo "error: No project name set" . PHP_EOL;
echo "eg): php {$laravel_plus_basename}/create YourProject" . PHP_EOL;
die;
}
return $argv[1];
}