Skip to content

Commit 3424b38

Browse files
committed
Adjustment and optimization
1 parent 32dbe88 commit 3424b38

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

src/SwordEvent.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@
1414
class SwordEvent
1515
{
1616
/**
17-
* EasySwoole框架的 bootstrap 事件
17+
* 入口启动事件
1818
* 发生在框架初始化之前
1919
*/
2020
public static function bootstrap()
2121
{
2222
// 加载助手函数
2323
require_once __DIR__."/helper.php";
2424

25+
// 底层框架初始化
26+
require_once __DIR__."/initialize.php";
27+
2528
// 时区设置
2629
date_default_timezone_set(config('app.timezone') ?: 'Asia/Shanghai');
2730

@@ -40,4 +43,4 @@ public static function mainServerCreate()
4043

4144
}
4245

43-
}
46+
}

src/helper.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<?php declare(strict_types=1);
22
/**
3-
* Sword 助手函数
4-
* 任何地方都可以通过助手函数名快速调用
3+
* Sword框架初始化
54
* @link http://sword.kyour.cn
65
* @document http://sword.kyour.cn/doc
76
* @contact kyour@vip.qq.com
87
* @license http://github.com/php-sword/sword/blob/master/LICENSE
9-
*/
10-
8+
*/
119
use EasySwoole\RedisPool\RedisPool;
1210

1311
define('SWORD_NULL', "SWORD_NULL_VALUE");
1412
define('SWORD_REDIS_EXISTS', "SWORD_REDIS_EXISTS_VALUE");
1513

14+
/**
15+
* Sword 助手函数
16+
* 任何地方都可以通过助手函数名快速调用
17+
*/
1618
if (!function_exists('container')) {
1719
/**
1820
* 容器操作 全局变量

src/initialize.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php declare(strict_types=1);
2+
/**
3+
* Easyswoole框架初始化
4+
* 版本 3.4
5+
*/
6+
use EasySwoole\EasySwoole\Command\CommandRunner;
7+
use EasySwoole\Command\Caller;
8+
9+
defined('IN_PHAR') or define('IN_PHAR', boolval(\Phar::running(false)));
10+
defined('RUNNING_ROOT') or define('RUNNING_ROOT', ROOT_PATH);
11+
defined('EASYSWOOLE_ROOT') or define('EASYSWOOLE_ROOT', IN_PHAR ? \Phar::running() : ROOT_PATH);
12+
13+
if(file_exists(EASYSWOOLE_ROOT.'/bootstrap.php')){
14+
require_once EASYSWOOLE_ROOT.'/bootstrap.php';
15+
}
16+
17+
$caller = new Caller();
18+
$caller->setScript(current($argv));
19+
$caller->setCommand(next($argv));
20+
$caller->setParams($argv);
21+
reset($argv);
22+
23+
$ret = CommandRunner::getInstance()->run($caller);
24+
if($ret && !empty($ret->getMsg())){
25+
echo $ret->getMsg()."\n";
26+
}

0 commit comments

Comments
 (0)