Skip to content

Commit

Permalink
更新2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
doyouhaobaby committed Dec 1, 2024
1 parent 8a9aeee commit f06b066
Show file tree
Hide file tree
Showing 19 changed files with 155 additions and 271 deletions.
123 changes: 34 additions & 89 deletions MORE-zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ php leevel server <Visite http://127.0.0.1:9527/>
```

- Home http://127.0.0.1:9527/
- MVC router http://127.0.0.1:9527/api/test
- MVC restful router http://127.0.0.1:9527/restful/123
- MVC restful router with method http://127.0.0.1:9527/restful/123/show
- Annotation api router http://127.0.0.1:9527/api/v1/demo/liu
- Annotation web router http://127.0.0.1:9527/web/v2/demo
- php leevel link:static http://127.0.0.1:9527/static/css/page.css
- php leevel link:attachments http://127.0.0.1:9527/attachments/.gitignore
- php leevel link:apis http://127.0.0.1:9527/apis/
- php leevel link:debugbar http://127.0.0.1:9527/debugbar/debugbar.css

## 连接数据库

Expand All @@ -52,25 +43,23 @@ CREATE DATABASE IF NOT EXISTS myapp DEFAULT CHARSET utf8 COLLATE utf8_general_ci
vim .env
...
// Database
# Database
DATABASE_DRIVER = mysql
DATABASE_HOST = 127.0.0.1
DATABASE_PORT = 3306
DATABASE_NAME = queryphp_development_db
DATABASE_USER = root
DATABASE_PASSWORD =
...
to
...
// Database
DATABASE_DRIVER = mysql
DATABASE_HOST = 127.0.0.1
DATABASE_PORT = 3306
DATABASE_NAME = myapp
DATABASE_PORT = 3307
DATABASE_NAME = apiql_data1
DATABASE_NAME_PREFIX = apiql_data
DATABASE_USER = root
DATABASE_PASSWORD = 123456
# Common database
DATABASE_COMMON_DRIVER = mysql
DATABASE_COMMON_HOST = 127.0.0.1
DATABASE_COMMON_PORT = 3307
DATABASE_COMMON_NAME = apiql_common
DATABASE_COMMON_NAME_PREFIX = apiql_common
DATABASE_COMMON_USER = root
DATABASE_COMMON_PASSWORD = 123456
...
```
Expand All @@ -79,47 +68,14 @@ DATABASE_PASSWORD = 123456

```diff
- $php leevel migrate:migrate
- $php php leevel migrate:migrate --environment=data
- php leevel migrate:migrate --environment=common
+ $composer migrate
+ $composer migrate-data
+ $composer migrate-common
$php leevel server
```

### 测试连接数据库

<http://127.0.0.1:9527/api/entity>

```
{
count: 4,
:trace: {
...
}
}
```

## 登陆到 QueryVue 后台

### 安装前端

前端项目 <https://github.com/hunzhiwange/queryvue>

第一步安装前端,细节信息可以在 `README-zh-CN.md` 查看.

```
cd data/codes/queryvue/
npm install -g cnpm --registry=https://registry.npm.taobao.org // Just once
cnpm install
npm run serve # npm run dev
```

### 登陆后台

接着访问这个登陆地址. <http://127.0.0.1:9528/#/login>

```
user: admin
password: 123456
```

## 运行测试

### 首先创建一个用于测试的数据库 test.
Expand All @@ -134,34 +90,34 @@ CREATE DATABASE IF NOT EXISTS test DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
vim .env.phpunit
...
// Database
# Database
DATABASE_DRIVER = mysql
DATABASE_HOST = 127.0.0.1
DATABASE_PORT = 3306
DATABASE_NAME = test
DATABASE_USER = root
DATABASE_PASSWORD =
...
to
...
// Database
DATABASE_DRIVER = mysql
DATABASE_HOST = 127.0.0.1
DATABASE_PORT = 3306
DATABASE_NAME = test
DATABASE_PORT = 3307
DATABASE_NAME = apiql_data1
DATABASE_NAME_PREFIX = apiql_data
DATABASE_USER = root
DATABASE_PASSWORD = 123456
# Common database
DATABASE_COMMON_DRIVER = mysql
DATABASE_COMMON_HOST = 127.0.0.1
DATABASE_COMMON_PORT = 3307
DATABASE_COMMON_NAME = apiql_common
DATABASE_COMMON_NAME_PREFIX = apiql_common
DATABASE_COMMON_USER = root
DATABASE_COMMON_PASSWORD = 123456
...
```

### 执行数据库迁移命令

```diff
- php leevel migrate:migrate -e env.phpunit
- php leevel migrate:migrate --env=env.phpunit
+ $composer migrate-phpunit
- php leevel migrate:migrate --env=env.phpunit --environment=common
+ $composer migrate-phpunit-common
```

### 运行
Expand All @@ -180,7 +136,7 @@ $vim .env.phpunit # modify database redis and other

### 关闭调试

修改 .env 或者 bootstrap/config.php.
修改 .env

```
// Environment production、testing and development
Expand Down Expand Up @@ -282,17 +238,6 @@ RoadRunner 和 php-fpm 保持一致
```
root@vagrant-ubuntu-10-0-2-5:/data/codes/queryphp# /data/server/roadrunner-2.12.1-darwin-amd64/rr serve
2022-12-10T16:43:30.226+0800 DEBUG rpc plugin was started {"address": "tcp://127.0.0.1:6001", "list of the plugins with RPC methods:": ["app", "informer", "resetter"]}
[INFO] RoadRunner server started; version: 2.12.1, buildtime: 2022-12-01T12:41:50+0000
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9522, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9525, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9523, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9529, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9528, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9526, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9527, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9524, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.525+0800 DEBUG http http server was started {"address": "0.0.0.0:9527"}
2022-12-10T16:44:08.664+0800 INFO http http log {"status": 200, "method": "GET", "URI": "/", "remote_address": "127.0.0.1:56516", "read_bytes": 0, "write_bytes": 18441, "start": "2022-12-10T16:44:08.644+0800", "elapsed": "19.623241ms"}
```

## 统一团队代码风格
Expand Down
121 changes: 33 additions & 88 deletions MORE.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ php leevel server <Visite http://127.0.0.1:9527/>
```

- Home http://127.0.0.1:9527/
- MVC router http://127.0.0.1:9527/api/test
- MVC restful router http://127.0.0.1:9527/restful/123
- MVC restful router with method http://127.0.0.1:9527/restful/123/show
- Annotation api router http://127.0.0.1:9527/api/v1/demo/liu
- Annotation web router http://127.0.0.1:9527/web/v2/demo
- php leevel link:static http://127.0.0.1:9527/static/css/page.css
- php leevel link:attachments http://127.0.0.1:9527/attachments/.gitignore
- php leevel link:apis http://127.0.0.1:9527/apis/
- php leevel link:debugbar http://127.0.0.1:9527/debugbar/debugbar.css

## Connect database

Expand All @@ -52,25 +43,23 @@ CREATE DATABASE IF NOT EXISTS myapp DEFAULT CHARSET utf8 COLLATE utf8_general_ci
vim .env
...
// Database
# Database
DATABASE_DRIVER = mysql
DATABASE_HOST = 127.0.0.1
DATABASE_PORT = 3306
DATABASE_NAME = queryphp_development_db
DATABASE_USER = root
DATABASE_PASSWORD =
...
to
...
// Database
DATABASE_DRIVER = mysql
DATABASE_HOST = 127.0.0.1
DATABASE_PORT = 3306
DATABASE_NAME = myapp
DATABASE_PORT = 3307
DATABASE_NAME = apiql_data1
DATABASE_NAME_PREFIX = apiql_data
DATABASE_USER = root
DATABASE_PASSWORD = 123456
# Common database
DATABASE_COMMON_DRIVER = mysql
DATABASE_COMMON_HOST = 127.0.0.1
DATABASE_COMMON_PORT = 3307
DATABASE_COMMON_NAME = apiql_common
DATABASE_COMMON_NAME_PREFIX = apiql_common
DATABASE_COMMON_USER = root
DATABASE_COMMON_PASSWORD = 123456
...
```
Expand All @@ -79,47 +68,14 @@ DATABASE_PASSWORD = 123456

```diff
- $php leevel migrate:migrate
- $php php leevel migrate:migrate --environment=data
- php leevel migrate:migrate --environment=common
+ $composer migrate
+ $composer migrate-data
+ $composer migrate-common
$php leevel server
```

### Test with database

<http://127.0.0.1:9527/api/entity>

```
{
count: 4,
:trace: {
...
}
}
```

## Login to QueryVue

### Install frontend

Frontend project <https://github.com/hunzhiwange/queryvue>

First to install the frontend,see more detail on `README.md`.

```
cd cd data/codes/queryvue/
npm install -g cnpm --registry=https://registry.npm.taobao.org // Just once
cnpm install
npm run serve # npm run dev
```

### Login

Then visite it. <http://127.0.0.1:9528/#/login>

```
user: admin
password: 123456
```

## Run Tests

### First to create a test database.
Expand All @@ -134,34 +90,34 @@ CREATE DATABASE IF NOT EXISTS test DEFAULT CHARSET utf8 COLLATE utf8_general_ci;
vim .env.phpunit
...
// Database
# Database
DATABASE_DRIVER = mysql
DATABASE_HOST = 127.0.0.1
DATABASE_PORT = 3306
DATABASE_NAME = test
DATABASE_USER = root
DATABASE_PASSWORD =
...
to
...
// Database
DATABASE_DRIVER = mysql
DATABASE_HOST = 127.0.0.1
DATABASE_PORT = 3306
DATABASE_NAME = test
DATABASE_PORT = 3307
DATABASE_NAME = apiql_data1
DATABASE_NAME_PREFIX = apiql_data
DATABASE_USER = root
DATABASE_PASSWORD = 123456
# Common database
DATABASE_COMMON_DRIVER = mysql
DATABASE_COMMON_HOST = 127.0.0.1
DATABASE_COMMON_PORT = 3307
DATABASE_COMMON_NAME = apiql_common
DATABASE_COMMON_NAME_PREFIX = apiql_common
DATABASE_COMMON_USER = root
DATABASE_COMMON_PASSWORD = 123456
...
```

### Migrate

```diff
- $php leevel migrate:migrate -e env.phpunit
- php leevel migrate:migrate --env=env.phpunit
+ $composer migrate-phpunit
- php leevel migrate:migrate --env=env.phpunit --environment=common
+ $composer migrate-phpunit-common
```

### Run
Expand Down Expand Up @@ -282,17 +238,6 @@ The same with php-fpm
```
root@vagrant-ubuntu-10-0-2-5:/data/codes/queryphp# /data/server/roadrunner-2.12.1-darwin-amd64/rr serve
2022-12-10T16:43:30.226+0800 DEBUG rpc plugin was started {"address": "tcp://127.0.0.1:6001", "list of the plugins with RPC methods:": ["app", "informer", "resetter"]}
[INFO] RoadRunner server started; version: 2.12.1, buildtime: 2022-12-01T12:41:50+0000
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9522, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9525, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9523, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9529, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9528, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9526, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9527, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.524+0800 DEBUG server worker is allocated {"pid": 9524, "internal_event_name": "EventWorkerConstruct"}
2022-12-10T16:43:30.525+0800 DEBUG http http server was started {"address": "0.0.0.0:9527"}
2022-12-10T16:44:08.664+0800 INFO http http log {"status": 200, "method": "GET", "URI": "/", "remote_address": "127.0.0.1:56516", "read_bytes": 0, "write_bytes": 18441, "start": "2022-12-10T16:44:08.644+0800", "elapsed": "19.623241ms"}
```

## Unified Code Style
Expand Down
7 changes: 0 additions & 7 deletions README-zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,3 @@ php leevel server <Visite http://127.0.0.1:9527/>
## 版权协议

QueryPHP 是一个基于 [MIT license](http://opensource.org/licenses/MIT) 授权许可协议的开源软件.

##

```
php leevel make:entity print:print_template_content --env=env.phpunit
php leevel migrate:create PrintTemplateContent
```
4 changes: 2 additions & 2 deletions app/Controller/Swagger/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function handle(): string
protected function path(): array
{
return [
\Leevel::appPath('app/Controller/Swagger/ApiDemo.php'),
\App::proxy()->appPath('app/Controller/Swagger/ApiDemo.php'),
];
}

Expand All @@ -52,7 +52,7 @@ protected function path(): array
protected function basePath(): array
{
return [
\Leevel::path('app/Infra/Swagger'),
\App::proxy()->path('app/Infra/Swagger'),
];
}

Expand Down
2 changes: 1 addition & 1 deletion app/Controller/Swagger/Web.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Web extends Api
protected function path(): array
{
return [
\Leevel::appPath('app/Controller/Swagger/WebDemo.php'),
\App::proxy()->appPath('app/Controller/Swagger/WebDemo.php'),
];
}
}
Loading

0 comments on commit f06b066

Please sign in to comment.