From d078da67909cd73e870b6d3e5e7c3e3035cb812b Mon Sep 17 00:00:00 2001 From: yunshu Date: Sat, 9 Nov 2019 20:59:05 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 5 ++++ README.md | 66 ++++++++++++++++++++++++--------------------- config/database.php | 10 +++---- 3 files changed, 46 insertions(+), 35 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..9d5a2d7 --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +DB_HOSTNAME=127.0.0.1 +DB_DATABASE=lin_cms_tp5 +DB_USERNAME=root +DB_PASSWORD=123456 +DB_HOSTPORT=3306 diff --git a/README.md b/README.md index 11cc395..32efd0a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ +```

@@ -86,9 +87,9 @@ Lin 的服务端框架是基于 ThinkPHP5.1的,所以如果你比较熟悉Thin ## 获取工程项目 -```bash +​```bash git clone https://github.com/ChenJinchuang/lin-cms-tp5.git -``` +​``` > 执行完毕后会生成lin-cms-tp5目录 @@ -96,31 +97,35 @@ git clone https://github.com/ChenJinchuang/lin-cms-tp5.git 执行命令前请确保你已经安装了composer工具 -```bash +​```bash # 进入项目根目录 cd lin-cms-tp5 # 先执行以下命令,全局替换composer源,解决墙的问题 composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ # 接着执行以下命令安装依赖包 composer install -``` +​``` +## 复制环境配置文件 + +​```bash +cp .env.example .env +​``` ## 数据库配置 -Lin 需要你自己在 MySQL 中新建一个数据库,名字由你自己决定。例如,新建一个名为 lin-cms 的数据库。接着,我们需要在工程中进行一项简单的配置。使用编辑器打开 Lin 工程根目录下``/config/database.php``,找到如下配置项: - -```php -// 服务器地址 - 'hostname' => '', -// 数据库名 - 'database' => 'lin-cms', -// 用户名 - 'username' => 'root', -// 密码 - 'password' => '', - - //省略后面一堆的配置项 -``` +Lin 需要你自己在 MySQL 中新建一个数据库,名字由你自己决定。例如,新建一个名为 lin-cms 的数据库。接着,我们需要在工程中进行一项简单的配置。修改.env: + +​``` +# 服务器名 +DB_HOSTNAME= +# 数据库名 +DB_DATABASE=lin_cms +# 用户名 +DB_USERNAME= +# 密码 +DB_PASSWORD= +DB_HOSTPORT= +​``` **请务必根据自己的实际情况修改此配置项** @@ -130,13 +135,13 @@ Lin 需要你自己在 MySQL 中新建一个数据库,名字由你自己决定 配置完数据库连接信息后,我们需要为数据库导入一些核心的基础表,在项目根目录中,打开命令行,输入: -```bash +​```bash php think migrate:run -``` +​``` 当你看到如下提示时,说明迁移脚本已经启动并在数据库中生成了相应的基础数据库表 -```php +​```php == 20190427113042 User: migrating == 20190427113042 User: migrated 0.0540s @@ -159,37 +164,37 @@ php think migrate:run == 20190427130637 LinPoem: migrated 0.0879s All Done. Took 0.6255s -``` +​``` 迁移成功后我们需要为lin_user表插入一条数据,作为超级管理员,方便你后续在前端项目中登陆和测试,继续在命令行中输入: -```bash +​```bash php think seed:run -``` +​``` 当你看到如下提示时,说明迁移脚本已经启动并在lin_user表中创建了一条记录 -```php +​```php == UserSeeder: seeding == UserSeeder: seeded 0.0351s All Done. Took 0.0385s -``` +​``` ## 运行 如果前面的过程一切顺利,项目所需的准备工作就已经全部完成,这时候你就可以试着让工程运行起来了。在工程的根目录打开命令行,输入: -```bash +​```bash php think run --port 5000 //启动thinkPHP内置的Web服务器 -``` +​``` 启动成功后会看到如下提示: -```php +​```php ThinkPHP Development server is started On You can exit with `CTRL-C` -``` +​``` 打开浏览器,访问``http://127.0.0.1:5000``,你会看到一个欢迎界面,至此,Lin-cms-tp5部署完毕,可搭配[lin-cms-vue](https://github.com/TaleLin/lin-cms-vue)使用了。 @@ -219,3 +224,4 @@ QQ 群号:643205479 微信搜索:林间有风 +``` \ No newline at end of file diff --git a/config/database.php b/config/database.php index 9133219..c55ba3b 100644 --- a/config/database.php +++ b/config/database.php @@ -13,15 +13,15 @@ // 数据库类型 'type' => 'mysql', // 服务器地址 - 'hostname' => 'localhost', + 'hostname' => env('DB_HOSTNAME', 'localhost'), // 数据库名 - 'database' => 'lin-test', + 'database' => env('DB_DATABASE', 'lin_test'), // 用户名 - 'username' => 'root', + 'username' => env('DB_USERNAME', 'root'), // 密码 - 'password' => '', + 'password' => env('DB_PASSWORD', ''), // 端口 - 'hostport' => '', + 'hostport' => env('DB_HOSTPORT', 3306), // 连接dsn 'dsn' => '', // 数据库连接参数 From 5c6aa42d34498e1246273e78e655bb622fdeb2e8 Mon Sep 17 00:00:00 2001 From: yunshu Date: Sat, 9 Nov 2019 21:01:47 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 32efd0a..e8c2a99 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -```

@@ -87,9 +86,9 @@ Lin 的服务端框架是基于 ThinkPHP5.1的,所以如果你比较熟悉Thin ## 获取工程项目 -​```bash +```bash git clone https://github.com/ChenJinchuang/lin-cms-tp5.git -​``` +``` > 执行完毕后会生成lin-cms-tp5目录 @@ -97,25 +96,25 @@ git clone https://github.com/ChenJinchuang/lin-cms-tp5.git 执行命令前请确保你已经安装了composer工具 -​```bash +```bash # 进入项目根目录 cd lin-cms-tp5 # 先执行以下命令,全局替换composer源,解决墙的问题 composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/ # 接着执行以下命令安装依赖包 composer install -​``` +``` ## 复制环境配置文件 -​```bash +```bash cp .env.example .env -​``` +``` ## 数据库配置 Lin 需要你自己在 MySQL 中新建一个数据库,名字由你自己决定。例如,新建一个名为 lin-cms 的数据库。接着,我们需要在工程中进行一项简单的配置。修改.env: -​``` +``` # 服务器名 DB_HOSTNAME= # 数据库名 @@ -125,7 +124,7 @@ DB_USERNAME= # 密码 DB_PASSWORD= DB_HOSTPORT= -​``` +``` **请务必根据自己的实际情况修改此配置项** @@ -135,13 +134,13 @@ DB_HOSTPORT= 配置完数据库连接信息后,我们需要为数据库导入一些核心的基础表,在项目根目录中,打开命令行,输入: -​```bash +```bash php think migrate:run -​``` +``` 当你看到如下提示时,说明迁移脚本已经启动并在数据库中生成了相应的基础数据库表 -​```php +```php == 20190427113042 User: migrating == 20190427113042 User: migrated 0.0540s @@ -164,37 +163,37 @@ php think migrate:run == 20190427130637 LinPoem: migrated 0.0879s All Done. Took 0.6255s -​``` +``` 迁移成功后我们需要为lin_user表插入一条数据,作为超级管理员,方便你后续在前端项目中登陆和测试,继续在命令行中输入: -​```bash +```bash php think seed:run -​``` +``` 当你看到如下提示时,说明迁移脚本已经启动并在lin_user表中创建了一条记录 -​```php +```php == UserSeeder: seeding == UserSeeder: seeded 0.0351s All Done. Took 0.0385s -​``` +``` ## 运行 如果前面的过程一切顺利,项目所需的准备工作就已经全部完成,这时候你就可以试着让工程运行起来了。在工程的根目录打开命令行,输入: -​```bash +```bash php think run --port 5000 //启动thinkPHP内置的Web服务器 -​``` +``` 启动成功后会看到如下提示: -​```php +```php ThinkPHP Development server is started On You can exit with `CTRL-C` -​``` +``` 打开浏览器,访问``http://127.0.0.1:5000``,你会看到一个欢迎界面,至此,Lin-cms-tp5部署完毕,可搭配[lin-cms-vue](https://github.com/TaleLin/lin-cms-vue)使用了。 @@ -223,5 +222,4 @@ QQ 群号:643205479 微信搜索:林间有风 - -``` \ No newline at end of file + \ No newline at end of file From b75c9b0adbb4a1ee754974e7e324614bcc2ccd44 Mon Sep 17 00:00:00 2001 From: yunshu Date: Sat, 9 Nov 2019 21:04:18 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 9d5a2d7..8da3cfe 100644 --- a/.env.example +++ b/.env.example @@ -1,5 +1,5 @@ DB_HOSTNAME=127.0.0.1 -DB_DATABASE=lin_cms_tp5 +DB_DATABASE=lin_cms DB_USERNAME=root DB_PASSWORD=123456 DB_HOSTPORT=3306 From 7d5dffade442b138dc7235365c0022e8f6b85c38 Mon Sep 17 00:00:00 2001 From: yunshu Date: Sun, 10 Nov 2019 11:30:05 +0800 Subject: [PATCH 4/5] =?UTF-8?q?Logger=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/api/behavior/Logger.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/application/api/behavior/Logger.php b/application/api/behavior/Logger.php index 34b4bbc..93de8d0 100644 --- a/application/api/behavior/Logger.php +++ b/application/api/behavior/Logger.php @@ -25,7 +25,6 @@ class Logger */ public function run($params) { - // 行为逻辑 if (empty($params)) { throw new LoggerException([ @@ -34,7 +33,7 @@ public function run($params) } if (is_array($params)) { - list('uid' => $uid, 'username' => $username, 'msg' => $message) = $params; + list($uid, $username, $message) = $params; } else { $uid = Token::getCurrentUID(); $username = Token::getCurrentName(); From 931350b41f8e392c6904f0fe0070adf4751b1a98 Mon Sep 17 00:00:00 2001 From: yunshu Date: Sun, 10 Nov 2019 12:09:50 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/common.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/application/common.php b/application/common.php index d7e857f..2a5aed8 100644 --- a/application/common.php +++ b/application/common.php @@ -45,7 +45,7 @@ function rand_char($length) return $str; } -function split_modules($auths, $key = 'module') +function split_modules($auths, $module = 'module') { if (empty($auths)) { return []; @@ -131,7 +131,9 @@ function paginate() $start = $start * $count; - if ($start < 0 || $count < 0) throw new ParameterException(); + if ($start < 0 || $count < 0) { + throw new ParameterException(); + } return [$start, $count]; } \ No newline at end of file