Skip to content

Commit

Permalink
update readme and php serve command
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Apr 27, 2021
1 parent 14f6bb1 commit ebd90a3
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 10 deletions.
79 changes: 75 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,11 +246,62 @@ kite gl db 'fix_210423,fix_210321'
kite gl db 'fix_210423,fix_210321' -f
```

## 其他工具命令
## 其他常用命令

**env**
### php开发服务器

显示环境变量信息:
`kite php serve` 可以快速启动一个php开发服务器。

![](resource/images/kite-php-serve.png)

**命令配置**

可用通过配置来设置默认的信息,这样就不用每次启动时设置参数了

```php
'php:serve' => [
'hce-file' => 'test/clienttest/http-client.env.json',
'hce-env' => getenv('APP_ENV') ?: 'dev',
// document root
'root' => 'public',
'entry' => 'public/index.php',
'php-bin' => 'php7'
// 'addr' => '127.0.0.1:8552',
],
```

**IDEA http-client环境**

内置支持IDEA的http-client环境文件。

如果你需要同时开发多个项目,都需要启动serve,此时一份通用的配置显然不行了。

这时 `hce-file`, `hce-env` 就可以排上用场,可以在每个项目里添加一份http-client环境文件,并且规划好每个服务的端口

示例 [http-client.env.json](test/clienttest/http-client.env.json)

```json
{
"dev": {
"host": "127.0.0.1:10106"
},
"test": {
"host": "127.0.0.1:10106"
}
}
```

这样通过 `kite php serve` 运行时,会自动读取当前环境的 `host` 设置作为启动服务的server地址。

```bash
kite php serve
```

![](resource/images/kite-php-serve-start.png)

### env环境信息

显示全部环境变量信息:

```bash
kite env
Expand All @@ -259,9 +310,29 @@ kite env
输出 `PATH` 信息:

```bash
kite env path
$ kite env path
Path Value
/usr/local/sbin
/usr/local/bin
/usr/bin
/bin
/usr/sbin

```

搜索环境变量或指定显示某个环境变量:

```bash
$ kite env ter
Matched Results(Kw:ter)
TERMINAL_EMULATOR JetBrains-JediTerm
TERM xterm-256color
ZSH_TMUX_TERM screen-256color

```

> Tips: 当 `kite env` 后面跟的是一个存在的环境变量名时,直接显示这个环境变量信息;否则进行模糊匹配,显示所有匹配的变量信息
## 扩展使用

### 使用简单脚本
Expand Down
6 changes: 5 additions & 1 deletion app/Console/Controller/PhpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public function csFixCommand(Input $input, Output $output): void
*/
public function serveCommand(Input $input, Output $output): void
{
$conf = $this->app->getParam('phpServe', []);
$conf = $this->app->getParam('php:serve', []);
if ($conf) {
$conf = array_merge(self::DEF_SERVE_CONF, $conf);

Expand All @@ -157,10 +157,14 @@ public function serveCommand(Input $input, Output $output): void
$pds = PhpDevServe::new($serveAddr, $docRoot, $entryFile);
$pds->setPhpBin($phpBin);

// \vdump($hceEnv , $hceFile);
if ($hceEnv && $hceFile) {
$loaded = $pds->loadHceFile($hceFile);
if ($loaded) {
$output->info('the http client env file is loaded');
$pds->useHceEnv($hceEnv);
} else {
$output->liteWarning('the http client env file is not exists');
}
}

Expand Down
2 changes: 1 addition & 1 deletion config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

return [
// @see app/Console/Controller/PhpController.php
'phpServe' => [
'php:serve' => [
'hce-file' => 'test/clienttest/http-client.env.json',
'hce-env' => getenv('APP_ENV') ?: 'development',
// 'entry' => 'public/index.php',
Expand Down
Binary file added resource/images/kite-php-serve-start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resource/images/kite-php-serve.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 1 addition & 4 deletions test/clienttest/http-client.env.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
{
"dev": {
"host": "127.0.0.1:10106",
"bid": 10006,
"id-value": 12345,
"username": "",
"password": "",
"my-var": "my-dev-value",
"form-type": "application/x-www-form-urlencoded"
"form-type": "application/json"
},
"testing": {
"host": "",
"bid": 10001,
"id-value": 12345,
"username": "",
"password": "",
Expand All @@ -19,7 +17,6 @@
},
"prod": {
"host": "example.com",
"bid": 10001,
"id-value": 6789,
"username": "",
"password": "",
Expand Down

0 comments on commit ebd90a3

Please sign in to comment.