fastadmin related documents

  1. directory structure

The FastAdmin directory structure follows the module design officially recommended by ThinkPHP5:

FastAdmin Project directory
├── addons                  //Plug in storage directory
├── application             //Application directory
│   ├── admin               //Background management application module
│   ├── api                 //API Application module
│   ├── common              //General application module
│   ├── extra               //Extended configuration directory
│   ├── index               //Foreground application module
│   ├── build.php
│   ├── command.php         //Command line configuration
│   ├── common.php          //General auxiliary function
│   ├── config.php          //Basic configuration
│   ├── database.php        //Database configuration
│   ├── route.php           //Routing configuration
│   ├── tags.php            //Behavior configuration
├── extend
│   └── fast                //FastAdmin extended auxiliary class directory
├── public                  //Frame entry directory
│   ├── assets
│   │   ├── build           //Resource directory for packaging JS and CSS
│   │   ├── css             //CSS style catalog
│   │   ├── fonts           //Font directory
│   │   ├── img             //Picture resource directory
│   │   ├── js
│   │   │   ├── backend
│   │   │   └── frontend    //Background function module JS file storage directory
│   │   ├── libs            //Bower resource pack location
│   │   └── less            //Less resource directory
│   └── uploads             //Upload file directory
│   ├── index.php           //Application Portal master file
│   ├── install.php         //FastAdmin installation boot
│   ├── admin.php           //Background entry file (it will be modified to random file name after automatic installation)
│   ├── robots.txt
│   └── router.php
├── runtime                 //Cache directory
├── thinkphp                //ThinkPHP5 framework core directory
├── vendor                  //Composer resource package location
├── .bowerrc                //Bower directory profile
├── .env.sample             //Environment configuration template (one copy can be copied to take effect as. env)
├──               //Project introduction
├── bower.json              //Bower front end package configuration
├── build.php
├── composer.json           //Composer package configuration
└── think                   //Command line console entry (enter with php think command)

    2. Application module

There are four application modules in FastAdmin by default: admin, api, common and index. You can also expand and develop your own application modules.

Background module (admin) is the core module in FastAdmin. The background module is divided into multiple functional modules such as system configuration, attachment management and plug-in management. More functional modules can be installed and uninstalled freely in plug-in management.

The front end of the background has carried out a large number of secondary development based on AdminLTE and Bootstrap, and RequireJS is used for JS modular management and loading.

The structure of the foreground module (index) is similar to the background function. Please refer to the chapter of the background module for details.

Common module is a special module. Direct access is prohibited by default. It is generally used to place some public classes or inherited base classes of other modules.

API module (api) is usually used to connect APP and provide interface to APP. At present, FastAdmin does not provide API related plug-ins and documents. You can directly refer to the official documents of ThinkPHP5.


3. One function module

Function modules refer to the function modules in the background management, such as our system configuration, attachment management and classification management (classification management is hidden by default in the new version and can be opened in permission management by itself).

Each functional module developed in the background is developed based on MVC design pattern. In FastAdmin, we provide the function of generating CRUD with one click. The file generated by CRUD is our standard MVC file.

The following are the documents involved in a standard function module

├── application
│   └── admin
│       ├── controller
│       │   └── Test.php        //Controller class
│       ├── lang
│       │   ├── zh-cn
│       │   │   └── test.php    //Functional language pack, loaded on demand
│       │   └── zh-cn.php       //Background language pack, loaded by default
│       ├── model
│       │   └── Test.php        //Model class
│       ├── validate
│       │   └── Test.php        //Verifier class
│       └── view
│           └── test
│               ├── index.html   //List view
│               ├── add.html     //Add view
│               └── edit.html    //Edit View
└── public
    └── assets
        └── js
            └── backend
                └── test.js      //Function module JS file

In FastAdmin, each function module corresponds to at least one function module JS file, that is, each controller corresponds to a JS file with the same name. Secondly, the method of each controller corresponds to the method with the same name in the JS file.

Refer to the controller chapter for detailed introduction of the specific controller, and refer to the front-end chapter for JS.

4. Form custom search

For example: test table

Modify controller test Code in PHP:

├── application
│   └── admin
│       ├── controller
│       │   └── Test.php        //Controller class

Find test PHP file and open it as follows:


namespace app\admin\controller;

use app\common\controller\Backend;

 * IP Address management
 * @icon fa fa-circle-o
class Test extends Backend

     * Ipaddress Model object
     * @var \app\admin\model\Ipaddress
    protected $searchFields = "vlanid,ipadd,location,category";
    protected $model = null;

    public function _initialize()
        $this->model = new \app\admin\model\Test;
        $this->view->assign("statusList", $this->model->getStatusList());

     * The default generated controller inherits five basic methods of index/add/edit/del/multi and three recycle bin methods of destroy/restore/recyclebin
     * Therefore, there is no need to write the code of adding, deleting, modifying and checking in the current controller, unless you need to control this part of logic yourself
     * Application / admin / library / traits / backend Copy the corresponding method in PHP to the current controller, and then modify it


protected$searchFields = "" in the above code. Add this method and fill in the field name you want to customize the search in quotation marks to realize the custom search. Multiple fields are separated by commas.

Tags: PHP fastadmin

Posted by pedrokas on Wed, 11 May 2022 05:42:50 +0300