FastAdmin是一款基于ThinkPHP5+Bootstrap的极速后台开发框架:开发文档
下面对环境搭建简要概述,希望后来者能少走弯路:
1. 百度搜索最新版wampserver, 安装并启动
2. forbidden 解决错误,appache 服务器配置
在浏览器输入127.0.0.1可以进入wamp页面,但输入localhost不可以,解决方法:
apache => httpd.conf => 修改Allow from 127.0.0.1为Allow from all => 重启restart
# onlineoffline tag - don't remove Order Deny,Allow Deny from all # Allow from 127.0.0.1 Allow from all
3.mysql密码重置 mysql密码配置(默认密码为空),选择myq console,一开始提示输入密码,直接回车就好(默认密码为空),然后执行下面几个命令:
mysql> use mysql; mysql> update user set password=password('ms2017!') where user='root'; # 新版本mysql不存在password 字段报错,需要修改为authentication_string, 即 mysql> update user set password=password('ms2017!') where user='root'; mysql> flush privileges; mysql> quit;
4. 下载最新版fastadmin并解压到 d:/wamp/www/ 文件夹下并改名fastad,浏览器打开 d:/wamp/www/fastad/public/install ,填写数据库名、mysql密码即可安装.
前往官网下载页面(https://www.fastadmin.net/download.html)下载完整包解压到你的项目目录 添加虚拟主机并绑定到项目中的public目录 访问 https://www.yoursite.com/install.php 进行安装
5. 利用phpmyadmin 在数据库中建表,注意每个字段都要有注释名
int 整型 自动生成type为number的文本框,步长为1 enum 枚举型 自动生成单选下拉列表框,注意phpmyqdmin生成enum类型字段会报错,需要编辑修改sql建表语句 set set型 自动生成多选下拉列表框 float 浮点型 自动生成type为number的文本框,步长根据小数点位数生成 text 文本型 自动生成textarea文本框 datetime 日期时间 自动生成日期时间的组件 date 日期型 自动生成日期型的组件 timestamp 时间戳 自动生成日期时间的组件 特殊字段 字段 字段名称 字段类型 字段说明 category_id 分类ID int 将生成选择分类的下拉框,分类类型根据去掉前缀的表名,单选 category_ids 多选分类ID varchar 将生成选择分类的下拉框,分类类型根据去掉前缀的表名,多选 weigh 权重 int 后台的排序字段,如果存在该字段将出现排序按钮,可上下拖动进行排序 createtime 创建时间 int 记录添加时间字段,不需要手动维护 updatetime 更新时间 int 记录更新时间的字段,不需要手动维护
6. 进入d:/wamp/www/fastad/ 文件夹下面,使用命令
php think crud -t table_name -u 1 # 根据数据表名一键生成增删查改页面和菜单。
常用命令
//生成fa_test表的CRUD php think crud -t test //生成fa_test表的CRUD且一键生成菜单 php think crud -t test -u 1 //删除fa_test表生成的CRUD php think crud -t test -d 1 //生成fa_test表的CRUD且控制器生成在二级目录下 php think crud -t test -c mydir/test //生成fa_test_log表的CRUD且生成对应的控制器为testlog php think crud -t test_log -c testlog //生成fa_test表的CRUD且对应的模型名为testmodel php think crud -t test -m testmodel //生成fa_test表的CRUD且生成关联模型category,外链为category_id,关联表主键为id php think crud -t test -r category -k category_id -p id //生成fa_test表的CRUD且所有以list或data结尾的字段都生成复选框 php think crud -t test --setcheckboxsuffix=list --setcheckboxsuffix=data //生成fa_test表的CRUD且所有以image和img结尾的字段都生成图片上传组件 php think crud -t test --imagefield=image --setcheckboxsuffix=img //关联多个表,参数传递时请按顺序依次传递,支持以下几个参数relation/relationmodel/relationforeignkey/relationprimarykey/relationfields/relationmode php think crud -t test --relation=category --relation=admin --relationforeignkey=category_id --relationforeignkey=admin_id
7. 进入fastad 后台,修改角色和权限。
8. 根据实际需求,灵活修改页面显示等样式和功能。