-
Notifications
You must be signed in to change notification settings - Fork 0
/
artisan.php
55 lines (47 loc) · 956 Bytes
/
artisan.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
<?php
/**
* 框架命令行工具
*/
final class artisan extends base
{
public function __construct()
{
$this->onlyCli();
}
public function index()
{
}
public function release($update=true)
{
function_exists('opcache_reset')&&opcache_reset();
if(substr(__FILE__,0,4)!='phar')
{
$update?$this->update(0,true):null;
$script=$_SERVER['argv'][0];
$subject=file_get_contents($script);
$pattern='/base::version\((\d+)\)/';
$data=preg_replace_callback($pattern,function($matches)
{
$version=$matches[1]+1;
echo PHP_EOL."new version {$version}".PHP_EOL;
return "base::version({$version})";
},$subject);
return $data==$subject?false:file_put_contents($script,$data);
}
}
public function update($time=60,$once=false)
{
app::timer(function() use($time)
{
try
{
$this->gitpull('password');
}
catch(Exception $e)
{
echo $e->getMessage();
}
sleep($time);
},$once);
}
}