


CRUD generator DBuilder design and implementation, crud generator dbuilder_PHP tutorial
Design and implementation of CRUD generator DBuilder, crud generator dbuilder
Chapter 1 Introduction
1.1 Research background and significance
With the development of computer software technology, databases have become the most widely used medium for storing formatted data, and database program development technology has also become increasingly perfect. Large-scale ORM frameworks have made database program development simple, and have become the basis for operating relational databases. mainstream approach. The main code of the database program is CRUD (create, retrieve, update, delete) code. With the improvement of the ORM framework function, writing CRUD code also derives its fixed process. CRUD code that operates on different database tables is also highly reusable. . Currently, writing repetitive CRUD codes has become the norm for developers, which not only seriously reduces their enthusiasm, but also reduces their development efficiency. Therefore, there is an urgent need for a product that can quickly generate CRUD codes in order to reduce this work and improve development efficiency.
1.2 Current Research Status
At present, some CRUD generator products with high usability that solve the above needs have been produced abroad: CrudKit, CRUD-Admin-Generator, Dadabik, GroceryCrud, SximoBuilder. Each of these products has its own characteristics, but they also have one thing in common: they are all developed based on PHP (this is determined to a certain extent by the flexibility and parsing of PHP syntax). SximoBuilder is a typical representative. Although SximoBuilder has a unique design, high usability, and high popularity, it also has the following shortcomings:
- Does not support custom form controls;
- Does not support multiple databases;
- The verification rules are incomplete and asynchronous verification is not supported;
- The code is extremely redundant.
However, for today's increasingly complex web programs, the above points are issues that must be considered during the development process. Therefore, it is imperative to develop a CRUD generator product that not only has the existing functions of SximoBuilder but also improves its shortcomings. OK.
1.3 Research content
Based on the current research status of CRUD generators at home and abroad, the author developed a CRUD generator called DBuilder (D is the abbreviation of DataAdministrator).
DBuilder draws on SximoBuilder’s idea that modules are code units and code is generated from templates, but it has a code generator logic that is completely different from SximoBuilder. On the basis of realizing the core code generation and general CRUD functions of SximoBuilder, it improves its shortcomings by rewriting the code logic: large code redundancy and lack of front-end verification.
Chapter 2 DBuilder System Analysis
The main user groups of DBuilder are web backend administrators and developers, so its system analysis process will consider issues more from the perspective of web backend administrators and developers.
2.1 Requirements Analysis
The project needs to implement the following core functions.
1) Data source management
Users can configure multiple data sources for the project in the interface. The configured data source information includes database type, address, database name, port, user name, password and other information. Supports addition, deletion, modification and query of data sources to ensure that addition, deletion, modification and query of data sources will not easily cause system problems.
2) Code generation
This function is the core function of DBuilder. After selecting the data source and data table, the user can simply configure the fields of the database table. The configuration includes Form configuration, List (Table) list configuration, relationship configuration, Global property configuration. After the configuration is completed, DBuilder must be able to generate CRUD MVC code for the database table, that is, it needs to implement the CRUD available functions, but there is no need to write code.
3) DatabaseTable CRUD
The generated code must support the creation, deletion, update, and query operations of data table records.
4) Menu Management
DBuilder must be able to bind the generated code to a menu item, so that after the user clicks on the menu item, they can use the CRUD function generated by DBuilder. This menu must include the background menu, the front menu is not required.
5) User Management
Users need to implement multiple roles. It must be possible to use the email address as a unique identifier for the user and as a login parameter. In the future, we will also implement support for QQ, WeChat, and Sina Weibo's interconnected login based on OAuth2.0.
6) Permission Management
DBuilder must be able to implement three-dimensional configurability of the execution and access rights of different CRUD codes for different user roles. For example, there is a CRUD function module for article management. The user roles are divided into system administrator (SuperAdmin), administrator (Admin), and guest (Guest). Then DBuilder must be able to implement the following three-dimensional permission configuration and use it as all Module's default permissions.
Table 2-1 Module permission configuration table
用户组与权限 |
查看 |
编辑 |
删除 |
导出 |
SuperAdmin |
√ |
√ |
√ |
√ |
Admin |
√ |
√ |
√ |
|
Guest |
√ |
|
|
|
7) Site parameter configuration
DBuilder, as a web background program for a website, is also necessary to configure the global parameters of the site. These parameters include website name, keywords, contact address, friendly links, etc.
8) Operation log
DBuilder should record the user's operation information, including the pages visited, CRUD type executed, time and other information. The log recording format supports two methods: database and file.
9) Multiple language support
DBuilder should support switching between multiple languages. At least two languages, Chinese and English, should be supported, with Chinese as the default.
10) Multiple database types supported
DBuilder should support multiple types of databases, and currently mainly supports relational databases, including mysql, MS SqlServer, oracle, PostGreSQL, etc.
2.2 Data Prototype Analysis
The entities available for extraction according to requirements include: users, user groups, data sources, code modules, menus, and relationships: permissions and logs. The meanings of entities and relationships are as follows:
- User: indicates the user who uses DBuilder;
- User group: Indicates the type grouping of users. User types should include at least three types: guest, administrator, and super administrator;
- Data source: Indicates the database configuration included in DBuilder. The configuration of a data source contains the basic parameters required to connect to a database;
- Code module: represents the code module generated by DBuilder, describing the code files and configuration;
- Menu: Represents the left menu item of DBuilder;
- Permissions: Indicates the user group’s various operating permissions for each code module;
- Log: Indicates the user's CRUD access log for each code module.
The ER diagram of entities and relationships is as follows:
Figure 2-1 ER diagram
2.3 Principle Requirements
DBuilder should be made into a high-performance, highly available CRUD generator. To this end, the design of DBuilder should comply with the following principles:
- DBuilder should be so accurate that each database field can be configured;
- There should be a prototype of a WEB backend application, so that users can quickly build a complete WEB backend application on this basis;
- DBuilder should reduce SQL operations as much as possible. If necessary, it can use caching, asynchronous and other technologies to reduce request processing logic, improve page efficiency, and reduce user waiting time;
- DBuilder must have a beautiful, concise and intuitive user interface;
- DBuilder should leave a large number of expansion interfaces, allowing users to quickly implement more complex functions through secondary development.
Chapter 3 DBuilder System Design
3.1 System Architecture
DBuilder has the following two core components: Core CRUD module and GModule. GModule has an inheritance dependency relationship on the Core CRUD module. GModule is composed of MVC Code and CRUD Config; the Core CRUD module is manually written code, and GModule is the code generated by DBuilder; the Core CRUD module implements CRUD operations, and GModule implements extended functions. The figure below shows the composition and relationship of these two components
Figure 3-1 Concept and components
The following is a detailed explanation of the concepts, components, module relationships, and Build and CRUD processes designed in the figure.
3.1.1 Core CRUD module
The Core CRUD module implements core CRUD operations. All CRUD requests to the Controller in GModule MVC are eventually transferred to the Core CRUD module for processing. The Core CRUD module will open some pre-processing and post-processing interfaces for GModule to implement. These interfaces will be reflected in Model, Controller and View.
Core CRUD module mainly includes the following files
- app/controllers/admin/AdminController.php
- app/models/BaseModel.php
- app/config/crud/admin.php
- app/views/admin/core/list.blade.php
- app/views/admin/core/form.blade.php
Core CRUD module reads GModule Configuration to implement real CRUD operations.
3.1.2 GModule
GModule (Generated Module) not only implements the Core CRUD Module interface (MVC code), but also has its own configuration file (CRUD Configuration). Each GModule represents a database table as the main table and a collection of code files with CRUD functions (including the corresponding MVC Configuration code) . For example, a GModule generated by DBuilder, the main table is the core data source user table, and the name is User, then the User GModule should contain the following code file:
- controllers/UserController.php
- models/User.php
- views/user/_list.blade.php
- views/user/_form.blade.php
- views/user/view.blade.php
- config/crud/user.php
The naming of the code file depends on the name of the GModule. Therefore, in order to ensure that the generated code files do not conflict, the name of the GModule (GModule Key, GModule Name) is used as the unique identifier of the GModule. The information of each GModule is saved in the database. A new GModule operation will create all the above code files, update related files, and insert a GModule record into the database. An update GModule operation will only update the Configuration file.
GModule consists of MVC code and CRUD Configuration code, which are explained below:
- MVC code: used to implement extended interfaces. CRUD requests should first be routed to the Controller in GModule MVC. And GModule MVC should have an inheritance relationship with the MVC code of Core CRUD Module.
- CRUD Configuration code: implements the configuration of adding, deleting, modifying and querying parameters in the GModule main table. This file is placed in the app/config/crud/ directory and is defined in the format of php array. It includes configuration of parameters such as forms, lists, views, relationships, etc. for all fields, as well as global parameter configuration.
GModule does not represent a specific module, but refers to a type of module, which can be generated by DBuilder or manually created by developers. It is mainly used to implement the interface of Core CRUD Module, mainly including the following parts
1) Controller interface
Assume that the Controller of the GModule module is A and the Controller of the Core CRUD Module is B, then A should inherit from B. The CRUD request will be routed to A first, and the actual handler is B. A will implement the following interfaces opened by B.
- beforeListExcuteQuery(&querier): This interface is called before the List query executes the query, and the passed parameter is the query reference. Used to bind special query parameters before querying.
- beforeList(&data): This interface is called after the List query is executed and before the List view is rendered. The parameters passed are view parameter references, which include the queried model collection. It is used to post-process the queried model collection, or to bind some Module-specific parameters to the list view.
- beforeEditExcuteQuery(&querier): This interface is called before the Model queryer executes the query in the Edit request, passing the queryer reference. Used to bind special parameters required to query the model.
- beforeEdit(&data): This interface is called after the Model query in Edit is executed and before the view is rendered. It passes the view parameter reference, including the model queried by the query. Used for preprocessing before rendering.
- afterSave(&model): This interface is called after saving the edit in Edit. What is passed is the model that is saved in the database and the latest database record is persisted. Used to do some complex post-cascade processing on the model.
- beforeView(data): This interface is called after the View query is queried in the View request, and the reference of the view parameters is passed. Used to preprocess the view display.
2) Model interface
The Model in the GModule MVC code also inherits from BaseModel, and can be extended by implementing some interfaces opened by the BaseModel class.
formatXXXAttribute(): This interface is used to format a certain field. This product is based on Laravel, which already has a similar interface, which is getXXXXAttribute(). However, the priority of such an interface is higher than that of the field, which brings inconvenience to development in special cases, so a similar interface is designed with a lower priority than the field itself.
3) View interface
The extension interface of the view is different from the previous two, which is mainly reflected in the subview and view block, that is, based on the view of the Core CURD module, the view component is extended. By default, the Core CRUD MVC view generates a table or form that fills the page. The View interface will provide the ability to expand page components up, down, left, and right on the table.
4) Configuration
Each GModule corresponds to a Configuration file, which contains the GModule's configuration parameters for each field of the main table, as well as layout parameters.
3.1.3 Module relationship
CRUD requests are routed to the Controller of GModule. The GModule code implements the open interface of Core CRUD MVC, and the Core CRUD Module actually implements the CRUD operation on the database. The information of each GModule should be recorded in the database table in order to give the GModule associated menus, control permissions, record operation logs, etc. The relationship between some major modules is shown in the figure below.
Figure 3-2 Module Relationship
As can be seen from Figure 2-2, the GModule management module generates a GModule A according to the user configuration. When the user's CRUD request reaches GModule A, GModule will transfer the request to Core CRUD for processing, and the Core CRUD module will then Perform CRUD operations on the database with SQL.
3.1.4 Build and CRUD process
The solution of the DBuilder project hands over the real CRUD operations to the Core CRUD Module for execution. The CRUD parameters are composed of GET or POST request parameters and GModule Configuration, and the MVC code of GModule is only to implement some of the prerequisites opened by Core CRUD MVC. Processing or post-processing interface.
Figure 2-3 is the core flow chart of DBuilder, including the process of generating Modules and processing CRUD requests. Figure 2-4 is the flow chart of generating Modules and processing CRUD requests in SximoBuilder.
Figure 3-3 DBuilder code generation and CRUD processing process
Figure 3-4 SximoBuilder code generation and CRUD processing process
Comparing the two, you can see that the biggest difference between the two is that DBuilder reuses a CRUD code instead of generating a set of CRUD codes for each Module that can be executed independently like Sximo does. The advantage of this is that it improves reusability and achieves scalability through the pre-processing/post-processing interface through Module CRUD MVC.
3.2 Core data source
Core data source is the default data source of DBuilder. Its type is mysql and the database name is dbuilder. This section will conduct detailed database design according to the "Data Prototype Analysis" section. In order to improve program performance, data source information is stored in the code file app/config/datasource.php. The file content is as follows:
array ( 'driver' => 'mysql',
|
field<🎜> |
type<🎜> |
default<🎜> |
info<🎜> |
<🎜>id<🎜> | <🎜>int<🎜> | <🎜>auto_increment<🎜> | <🎜>PRI<🎜> |
<🎜>module_id<🎜> | <🎜>int<🎜> | <🎜> <🎜> | <🎜> <🎜> |
<🎜>module_name<🎜> | <🎜>varchar(12)<🎜> | <🎜> <🎜> | <🎜> <🎜> |
<🎜>parent_id<🎜> | <🎜> <🎜> | <🎜>null<🎜> | <🎜>Parent menu item<🎜> |
<🎜>title<🎜> | <🎜>varchar(12)<🎜> | <🎜>module_title<🎜> | <🎜>Display name<🎜> |
<🎜>_order<🎜> | <🎜>int<🎜> | <🎜>0<🎜> | <🎜>Sort field<🎜> |
2) D_module table: records module information. Each record in the d_module table represents a Module generated by DBuilder.
Table 3-2 module information description
|
type
|
default
|
info |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
id |
|
<🎜>auto_increment<🎜> | <🎜>PRI<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>name<🎜> | <🎜>varchar(32)<🎜> | <🎜> <🎜> | <🎜>UIN<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>title<🎜> | <🎜>varchar(32)<🎜> | <🎜> <🎜> | <🎜>module title<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>note<🎜> | <🎜>varchar(32)<🎜> | <🎜> <🎜> | <🎜>module description<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>db_source<🎜> | <🎜>varchar(16)<🎜> | <🎜>core<🎜> | <🎜>Data source name<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>db_table<🎜> | <🎜>varchar(16)<🎜> | <🎜> <🎜> | <🎜>module main table<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>db_table_key<🎜> | <🎜>varchar(16)<🎜> | <🎜> <🎜> | <🎜>Main table PRI<🎜> |
<🎜>field<🎜> | <🎜>type<🎜> | <🎜>default<🎜> | <🎜>info<🎜> |
<🎜>id<🎜> | <🎜>int<🎜> | <🎜>auto_increment<🎜> | <🎜>PRI<🎜> |
<🎜>username<🎜> | <🎜>varhcar(64)<🎜> | <🎜> <🎜> | <🎜>Username<🎜> |
<🎜>email<🎜> | <🎜>varchar(64)<🎜> | <🎜> <🎜> | <🎜>Email<🎜> |
<🎜>password<🎜> | <🎜>varchar(64)<🎜> | <🎜> <🎜> | <🎜>HASH<🎜> |
<🎜>salt<🎜> | <🎜>varchar(64)<🎜> | <🎜> <🎜> | <🎜>Salt<🎜> |
<🎜>last_login<🎜> | <🎜>timestamp<🎜> | <🎜> <🎜> | <🎜>Last login time<🎜> |
<🎜>remember_token<🎜> | <🎜> <🎜> | <🎜> <🎜> | <🎜>Remember the password<🎜> |
<🎜>group_id<🎜> | <🎜>int<🎜> | <🎜> <🎜> | <🎜>Group ID<🎜> |
<🎜>field<🎜> | <🎜>type<🎜> | <🎜>default<🎜> | <🎜>info<🎜> |
<🎜>id<🎜> | <🎜>int<🎜> | <🎜>auto_increment<🎜> | <🎜>PRI<🎜> |
<🎜>name<🎜> | <🎜>varhcar(64)<🎜> | <🎜> <🎜> | <🎜>Group name<🎜> |
<🎜>note<🎜> | <🎜>varchar(128)<🎜> | <🎜> <🎜> | <🎜>Group Description<🎜> |
<🎜>level<🎜> | <🎜>int<🎜> | <🎜> <🎜> | <🎜>Group Level<🎜> |
5) D_group_access table: records the three-dimensional permission information of each GModule, different background user groups and various operation permissions.
Table 3-5 User group permissions table for Module
|
type
|
default
|
<🎜>info<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>id<🎜> | <🎜>int<🎜> | <🎜>auto_increment<🎜> | <🎜>PRI<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>group_id<🎜> | <🎜>int<🎜> | <🎜> <🎜> | <🎜>Group id<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>module_id<🎜> | <🎜>int<🎜> | <🎜> <🎜> | <🎜>Module module ID<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>edit<🎜> | <🎜>int<🎜> | <🎜>1<🎜> | <🎜>Editable<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>view<🎜> | <🎜>int<🎜> | <🎜>1<🎜> | <🎜>Can be viewed<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>delete<🎜> | <🎜>int<🎜> | <🎜>1<🎜> | <🎜>can be deleted<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>export<🎜> | <🎜>int<🎜> | <🎜>1<🎜> | <🎜>Exportable<🎜> |
<🎜>field<🎜> | <🎜>type<🎜> | <🎜>default<🎜> | <🎜>info<🎜> |
<🎜>id<🎜> | <🎜>int<🎜> | <🎜>auto_increment<🎜> | <🎜>PRI<🎜> |
<🎜>user_id<🎜> | <🎜>int<🎜> | <🎜> <🎜> | <🎜>User id<🎜> |
<🎜>ip_addr<🎜> | <🎜>varchar(15)<🎜> | <🎜> <🎜> | <🎜>Client IP<🎜> |
<🎜>module_id<🎜> | <🎜>int<🎜> | <🎜> <🎜> | <🎜>Accessed moduleid<🎜> |
<🎜>module_title<🎜> | <🎜>varchar(16)<🎜> | <🎜> <🎜> | <🎜> <🎜> |
<🎜>task<🎜> | <🎜>varchar(16)<🎜> | <🎜> <🎜> | <🎜>Operation<🎜> |
<🎜>created_at<🎜> | <🎜>timestamp<🎜> | <🎜> <🎜> | <🎜>Exportable<🎜> |
3.3 Data source management module
DBuilder needs to support multiple data sources and multiple types of databases. Data source information is stored in the d_database table. Considering that database operations are frequent operations, if the data source information is saved in the database, each database operation will require one more data source query operation, which wastes performance. Then DBuilder should not save the data source information in the database, but in the code file. Data source management information includes data source name (the unique identifier of the data source, DBuilder’s default data source name is core), database type, address, port, database name, user name, password and other information. Because the data source management module does not perform addition, deletion, modification, and query operations on tables, the data source management module is not a GModule module. The code for this module is entirely hand-written.
3.4 GModule management module
DBuilder will use the GModule named "Module" as the user interface for generating GModule. This module is called the GModule management module. In other words, the GModule management module itself is a GModule, and the main table of the GModule is the core data. In the database table that stores GModule information in the source, change the name of GModule to "Module". GModule management module contains all code files and database records for creating, updating and deleting GModule. The creation and deletion of GModule requires updating the global GModule routing.
1) GModule routing
The GModule route is defined in an independent code file. It is a string with the GModule name divided by minus signs and all lowercase as the key (for example: the GModule name is OrderItem, then the key value is order-item), with Module The class name of the Controller class is a map dictionary of values, and the GModule routing is global.
2) GModule New & Update
Creating a new GModule will generate a record in the database, generate all module files, and update routes. The update operation only modifies the configuration file. Both new creation and update use the same editing view, which is a graphical configuration interface for GModule Configuration.
3) GModule Delete
GModule deletion will delete all GModule MVC code, delete GModule Configuration code, delete database table records, and update GModule routing.
3.5 Core CRUD module
Core CRUD module is the actual processor of DBuilder to handle CRUD requests. It consists of the following parts:
1) Parameter analysis initialization
Initialize the Model and instantiate a Module's Model object as the initial queryer. Load Module Configuration, set default values for unset values, and aggregate parameters.
2) Form Form
Mainly includes new and update functions. Determine whether it is a new or update operation based on whether the primary key of the GModule main table primaryKey is set. The picture below is the process of the Form module
Figure 3-5 Form execution process
Form is divided into two parts. The first part renders the Form page for the user to fill in. The second part is saved as Form.
When rendering a Form page, you need to consider how to handle Form controls and fields with foreign key relationships. Form controls need to support types including text, text_date, text_datetime, textarea, select, radio, checkbox, file, hidden, address, and custom. Custom controls should inherit the FormControl class, and the rendering of custom controls is completed by the render method of the control. Form rendering needs to determine related fields for auxiliary loading. For example, when editing the post table, the post table has a field called category_id, which represents the column ID of the article and corresponds to the id field of the category table. At this time, you need to use select, radio, and checkbox controls to load category_id to facilitate user input. For example, if you use the select control, category.id should be used as the value of the option, and category.name should be used as the text in the option. This is also done to facilitate user input. This step has something in common with searching in List, so the code can be reused.
Form saving needs to consider the saving of some custom controls. The saving of custom controls is completed by the onSave method of the custom control class. When saving the Form, you also need to consider saving the relationship. By default, the subsidiary tables should be updated in cascade. After the user completes the input and clicks Save, the Form form has the following steps:
- Verify according to the validation rules configured in the field;
- The relationship in the Module Configuration should be judged for analysis and necessary cascading operations should be performed;
- And call the onSave method of the custom control;
- The main table data should be updated or created last;
- Jump: If the update or new creation is successful, it will jump to List, if it fails, it will jump to Form.
Form also needs to open the corresponding pre-processing and post-processing interfaces.
3) List List(Table)
List is a paging Table, which displays paging data according to the field configuration in Module Configuration. Supports list search, sorting, check deletion, export and other functions;
- Pagination display data uses the Model obtained by the InitQuerier module as the queryer, combined with paging, to query the basic data list. The paging type is full page refresh type (non-asynchronous paging);
- List search: supports fields where search is not equal to false defined in Module Configuration as search conditions. The search relationship is a logical AND relationship. And reflected on the GET parameters. The search input control is determined based on the form type of the field. Fields defined as select, radio, and checkbox controls in the Form will use the select control as the input control in the List;
- List sorting: Fields with form.sort not equal to false defined in Module Configuration are used as sortable fields. Sorting only supports sorting by a single field, and the descending order includes ascending order and descending order;
- List multi-select operations mainly support multi-select deletion and multi-select copy operations. Any deletion operation requires confirmation;
- The supported operations for each row of List data are given according to the configuration in Module Configuration. By default, three operations are supported: edit, delete, and view;
- List should also open preprocessing/postprocessing interfaces to Module CRUD MVC.
4) View View
View is temporarily based on Form and provides pre-processing and post-processing interfaces, but does not allow editing.
Chapter 4 DBuilder System Implementation
4.1 Directory structure
The code is stored in sub-directories according to concepts such as front-end resources, MVC, Configuration, and Library. A description of the main directories is given in the table below:
Table 4-2 Main directory of code
|
Function
|
||||||||||||||||||||||||||||
assets |
This directory stores various front-end resources. Includes bootstrap, as well as custom css and js files.
|
||||||||||||||||||||||||||||
plugins
|
Directory that stores special front-end plug-ins, such as rich text editors, video and audio plug-ins, etc.
|
||||||||||||||||||||||||||||
<🎜>app/controllers/admin<🎜> | <🎜> Directory that stores controllers in MVC. Among them, the core of DBuilder is in the admin directory. <🎜> | ||||||||||||||||||||||||||||
<🎜>app/models<🎜> | <🎜>The directory that stores the models in MVC. Used for database queries. <🎜> | ||||||||||||||||||||||||||||
<🎜>app/views<🎜> | <🎜>The directory that stores views in MVC. The file name is in the format *.blade.php. <🎜> | ||||||||||||||||||||||||||||
<🎜>app/library<🎜> | <🎜> Directory that stores PHP auxiliary classes and PHP libraries. <🎜> | ||||||||||||||||||||||||||||
<🎜>app/config/crud<🎜> | <🎜>The directory where Module Configuration is stored. <🎜> |
<🎜>Configuration Key<🎜> | <🎜>Type<🎜> | <🎜>Default value<🎜> | <🎜>Meaning<🎜> |
<🎜>fields<🎜> | <🎜>array<🎜> | <🎜>array()<🎜> | <🎜>Field list<🎜> |
<🎜>fields.field_name<🎜> | <🎜>array<🎜> | <🎜>array()<🎜> | <🎜>Configuration of field_name field<🎜> |
<🎜>fields.field_name.label<🎜> | <🎜>string<🎜> | <🎜>UP(field_name)<🎜> | <🎜>The content displayed in the header of the list table and the content next to the form control<🎜> |
<🎜>fields.field_name.form<🎜> | <🎜>array<🎜> | <🎜>array()<🎜> | <🎜>Form configuration of field_name field, please refer to <🎜> for details <🎜>fields.field_name.form configuration<🎜> |
<🎜>fields.field_name.list<🎜> | <🎜>array<🎜> | <🎜>array()<🎜> | <🎜>List configuration of field_name field, please refer to <🎜> for details <🎜>fields.field_name.list configuration<🎜> <🎜> <🎜> |
<🎜>fields.field_name. relation<🎜> | <🎜>array<🎜> | <🎜>array()<🎜> | <🎜>Relationship between field_name fields<🎜> |
The form configuration description of each field in Table 4-3 is as shown in the following table:
Table 4-4 fields.field_name.form configuration
|
Value type
|
Default
|
Meaning |
||||||||||||||||||||||||||||||||||||||||||||||||
type |
|
<🎜>text<🎜> | <🎜>Form control type<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>show<🎜> | <🎜>bool<🎜> | <🎜>true<🎜> | <🎜>Whether it appears in the form<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>hidden<🎜> | <🎜>bool<🎜> | <🎜>false<🎜> | <🎜>Whether to hide the space in the form<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>rule<🎜> | <🎜>string<🎜> | <🎜>required<🎜> | <🎜>Validation Rules<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>ajax_validate<🎜> | <🎜>bool<🎜> | <🎜>false<🎜> | <🎜>Whether to verify asynchronously<🎜> | ||||||||||||||||||||||||||||||||||||||||||||||||
<🎜>placeholder<🎜> | <🎜>string<🎜> | <🎜> <🎜> | <🎜>Prompts in controls<🎜> |
<🎜>Configuration Key<🎜> | <🎜>Value type<🎜> | <🎜>Default<🎜> | <🎜>Meaning<🎜> |
<🎜>show<🎜> | <🎜>bool<🎜> | <🎜>true<🎜> | <🎜>Whether it appears in the form<🎜> |
<🎜>sort<🎜> | <🎜>bool<🎜> | <🎜>true<🎜> | <🎜>Whether the field can be sorted, it can be sorted by default<🎜> |
<🎜>search<🎜> | <🎜>bool,array<🎜> | <🎜>array()<🎜> | <🎜>Whether it is searchable and search rules<🎜> |
<🎜> <🎜> | <🎜>string<🎜> | <🎜> <🎜> | <🎜>Prompts in controls<🎜> |
<🎜>Configuration Key<🎜> | <🎜>Value type<🎜> | <🎜>Default<🎜> | <🎜>Meaning<🎜> |
<🎜>table<🎜> | <🎜>string<🎜> | <🎜> <🎜> | <🎜>Association table<🎜> |
<🎜>foreign_key<🎜> | <🎜>string<🎜> | <🎜>id<🎜> | <🎜>Corresponds to the fields in the related table<🎜> |
<🎜>show<🎜> | <🎜>string<🎜> | <🎜> <🎜> | <🎜>A field in the associated table. When escaping is required, this field will be used to display instead of the field_nae field<🎜> |
<🎜>as<🎜> | <🎜>string<🎜> | <🎜>table_show<🎜> | <🎜>Which field should be used to represent the value from the escaped query? This is mainly to prevent duplicate fields in the main table and related tables<🎜> |
The following is the Configuration file of a GModule named post


4.3 Data source management module implementation
The data source management module completes the configuration of the app/config/datasource.php file based on the web interface. Contains data source list page, data source creation and editing page.
- Data source list page: The corresponding request path is admin/data-source/list. This page reads the DataSource file and renders the List (table) page. The password is not displayed.
- Data source editing page: The corresponding request path is admin/data-source/edit, the GET request reads the DataSource price inquiry content and renders the form, and the POST request outputs the data source parameters to the DataSource file. This page provides a test connection function. The implementation method is to connect to the database based on the data source parameters of the form and execute a SQL statement. Whether the connection is successful depends on whether the SQL is executed successfully.
The core controller code that implements data source management is placed in the DataSourceController.php file.



Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Alipay PHP...

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

Article discusses late static binding (LSB) in PHP, introduced in PHP 5.3, allowing runtime resolution of static method calls for more flexible inheritance.Main issue: LSB vs. traditional polymorphism; LSB's practical applications and potential perfo

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,
