Home  >  Article  >  PHP Framework  >  Basic process of fastadmin plug-in development based on TP framework

Basic process of fastadmin plug-in development based on TP framework

世界的背影
世界的背影Original
2020-05-01 18:12:224393browse

什么是fastadmin?

FastAdmin是一款基于ThinkPHP5+Bootstrap的极速后台开发框架。


fastadmin开发基础管理插件步骤

Basic process of fastadmin plug-in development based on TP framework

以一个学校管理插件为例

开发环境与工具

  • PHPSTORM

  • phpstudy

  • nginx1.15.11

  • mysql8.0

  • php7.3.4

准备工作

  • 配置站点

  • 我的域名设置为fast51admin.localhost.nyist.vip

Basic process of fastadmin plug-in development based on TP framework

第一步——安装fastadmin

安装fastadmin可以使用git克隆项目至本地或者下载安装包。

下载后解压到对应站点目录下,设置网站根目录至文件的public目录下(与tp一致)

解压后的文件

Basic process of fastadmin plug-in development based on TP framework

然后为网站设置对应的NGINX规则

如果成功则访问网站时可以看到,用户为admin,密码为123456

Basic process of fastadmin plug-in development based on TP framework

这是本次实例的规则

server {
	listen	80;
#该域名自动解析到本地127.0.0.1 无须配置本地host
	server_name fast51admin.localhost.nyist.vip;
#root路径需要修改,此次插件只使用后台,所以index为admin.php	
	root    D:/phpstudy_pro/WWW/fast51admin.localhost.vip/nyistSw/public;
	index   admin.php;
  if (!-e $request_filename) {
        rewrite  ^(.*)$  /admin.php?s=$1  last;
        break;
  }
	location ~ \.php$ {
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  admin.php;
		include  fastcgi.conf;
	}
}

Note: When using phpstudy, the rules are modified in the vhost file corresponding to the website.

Step 2 - Create a database table

Take the school management instance as an example

After you successfully install fastadmin, a database fast51## will be automatically generated

#The table we want to create is also in this database

The third step - one-click crud

This is a powerful function of fastadmin, you can use the command line with one click Generate controllers, models, views, validators, language packs, JS, etc. corresponding to the data table.

One-click command to generate crud

php think crud -t test


Here

“-t”The parameter specifies the data table you want to generate (you don’t need to write the prefix name)

Common parameters

-c, --controller[=CONTROLLER] Generated controller name, optional, automatically parsed based on table name by default


-m, --model[=MODEL] Generated model name, optional, The default is to automatically parse based on the table name


-i, --fields[=FIELDS] The fields visible in the generated data list, the default is all

-d, --delete [=DELETE] Delete mode will delete related files previously generated using CRUD commands


Step 4 - Generate MENU

fastadmin can quickly generate it with one click through the command console The background permission node menu rules, and the background management menu will also be changed simultaneously


One-click command to generate menu

php think menu -c test


Here

"-c"The parameter specifies the controller

After generation Appearance

Basic process of fastadmin plug-in development based on TP framework

The fifth step - test function

Test whether each automatically generated function is normal and meets your own needs

Sixth Step - One-click addon

FastAdmin can create a plug-in through the command line


One-click command to generate addon

php think addon -a mydemo -c create


Here

“-a”The parameter specifies the name of the add-on

After executing this command, the corresponding file will be generated in the addons directory

Basic process of fastadmin plug-in development based on TP framework

## The application corresponds to the application folder that comes with tpThat is where the files we generated in the previous steps are located

Step 7 - Implement the plug-in

Copy the files we generated in crud to the application in the corresponding directory

Export all our data tables and merge them into install.sql

Need to correspond in the plug-in directory Create the background management menu of the plug-in in the plug-in name.php.

Note: install.sql will be executed when the plug-in is installed for the first time

Basic process of fastadmin plug-in development based on TP frameworkStep 8 - Packing the plug-in


Command line packaging

//mydemo is the name of your plug-in directory


php think addon -a mydemo -c package


Manual packaging

Enter the plug-in directory you want to package, select all files, and compress them into zip packages

Summary

You can use fastadmin It greatly speeds up development, and there are many details that need to be consulted in the official documentation.

Official documentation link: https://doc.fastadmin.net/docs

Official plug-in documentation link: https://doc.fastadmin.net/developer/55.html

The above is the detailed content of Basic process of fastadmin plug-in development based on TP framework. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn