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. 根據實際需求,靈活修改頁面顯示等樣式和功能。