# 极简随手记php **Repository Path**: brisklan/bs_account_backend ## Basic Information - **Project Name**: 极简随手记php - **Description**: 极简随手记php - **Primary Language**: Unknown - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 9 - **Forks**: 2 - **Created**: 2024-12-22 - **Last Updated**: 2026-01-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 记账后端代码 =============== - 轻量级服务器,请各位大佬手下留情!!! - 轻量级服务器,请各位大佬手下留情!!! - 轻量级服务器,请各位大佬手下留情!!! - 轻量级服务器,请各位大佬手下留情!!! #### 代码图 代码关系 客户端端代码(uniapp vue2)在 https://gitee.com/brisklan/bs_account 管理后台代码(element UI)在 https://gitee.com/brisklan/bs_account_admin java版本后台(开发中):https://gitee.com/brisklan/bs_jizhang_java php运行环境要求thinkphp8.0+,开发环境php8.2,其它环境自己测试。 强制路由模式、基于thinkphp8开发 #### 1.项目依赖包 ```shell #①默认php版本 composer install #②指定php版本 php82 /usr/bin/composer install ``` ### php需要扩展: ①需要redis扩展(如果不用redis缓存则不用) ②开启fileinfo扩展 ③并把禁用函数putenv、 proc_open 移除 ④其它扩展:bcmath、curl、zip、pdo、openssl、json (这些在composer install的时候会检查你的环境是否已经安装,如果出现错误,请检查php环境是否安装相关扩展,比如【PHP extension ext-zip but it is missing from your system】) #### 1.项目初始化 复制.example.env 文件为.env,修改.env相关配置 ```shell cp .example.env .env ``` - 伪静态配置 ```shell location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } ``` - 给文件夹777权限 ```shell chmod -R 777 runtime/ chmod -R 777 /public/storage/ ```` #### 2.本地运行 ```shell php think run ``` #### 3.数据库配置 导入数据库文件 install/bs_jizhang.sql ### 命令行 - 队列,很多操作是队列方式执行的,如果不用队列在env文件中queue中配置is_open = false ```shell #队列 php think queue:listen --queue bs_jz_queue ``` - 生成账单 ```shell php think bill --type day # 生成日账单 php think bill --type month # 生成月账单 php think bill --type year # 生成年账单 php think bill --type week # 生成周账单 ``` ### 用crontab 定时 (www用户) /www/wwwroot/website - 切换crontab用户 ```shell crontab -e -u www ``` - crontab配置 ```shell 0 7 * * * cd /www/wwwroot/website && /usr/bin/php /www/wwwroot/website/think bill --type day 10 7 1 * * cd /www/wwwroot/website && /usr/bin/php /www/wwwroot/website/think bill --type month 20 7 1 1 * cd /www/wwwroot/website && /usr/bin/php /www/wwwroot/website/think bill --type year 30 7 * * 1 cd /www/wwwroot/website && /usr/bin/php /www/wwwroot/website/think bill --type week #每天0点之前统计昨天的数据 0 0 * * * cd /www/wwwroot/website && /usr/bin/php /www/wwwroot/website/think sys_statistics #每30分钟检查周期执行账单 0 */30 * * * cd /www/wwwroot/website && /usr/bin/php /www/wwwroot/website/think bill_check ``` ### 账单邮件通知 1. 邮件配置在config/email.php 2. 队列配置在config/queue.php 3. 发送采用异步延迟10秒推送邮件 4. 队列执行php think queue:listen #请用supervisor管理 ### 升级系统 请先备份数据库!!! 1. 代码升级:直接拉取代码 2. 数据库升级: - ①执行sql文件,默认数据库为bs_jizhang.sql是重置结构(如果已经正常运作,不建议这样做!!!)。 - ②查看update_sql.md是对应版本的数据库结构变化更新,建议对症下药,推荐按版本更新数据库结构,只需要执行对应的sql语句即可。 ### 其它 - sql报错 group by 和order by 问题,比如报错【SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'jizhang-app.bs_cashflows.id' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by】 这个问题一般都是在windows下面用mysql5.7出现的,解决方式就是在mysql_ini里面加入 ```sql sql_mode =STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION ``` 然后重启mysql服务即可