: This article mainly introduces the ThinkPHP project grouping configuration method analysis. if you are interested in the PHP Tutorial, you can refer to it. This article describes how to configure ThinkPHP project group. We will share this with you for your reference. The details are as follows:
Project Group Overview
Project grouping is an important mechanism of ThinkPHP. the Project grouping function can combine multiple projects in the past into one project and reuse public files, however, each group can have its own configuration files, public files, and language packs.
Take a common website as an example. if project groups are not used, the website foreground (provided to users for browsing) is usually used as a project. The background management part of the website may have independent configuration files, CSS files and templates, so it can be managed as another project. But in fact, both projects are website content, and they can share some content, such as database configuration files and even some model classes and cross-project operations.
Project grouping solves the common and individual problems between projects in the same system.
Project group configuration
You can enable the project group by configuring a simple project group in the system configuration file (Config/config. php.
There are five configurations related to the project grouping mode:
Configuration options |
Description |
Example or suggestion |
APP_GROUP_LIST |
List of all project groups. If this parameter is not set, the project group mode is disabled. |
'App _ GROUP_LIST '=> 'Home, Admin, User, Blog ', |
DEFAULT_GROUP |
The default project group name. The default value is Home. |
'Default _ group' => 'home ', |
APP_GROUP_DEPR |
Project group delimiter. the default delimiter is. (point), used to separate function A and route configuration. |
Recommended default |
TMPL_FILE_DEPR |
The delimiter between modules and operations in the template file. the default delimiter is/, which is only valid for project group deployment. |
We recommend that you use the U method to automatically generate a URL by default. |
VAR_GROUP |
Obtains the variable of the project group name. The default value is g. |
Index. php? G = Admin & m = Index & a = edit. the default value is recommended. |
When TMPL_FILE_DEPR is configured as _, the template file corresponding to the add operation in the Index module of the Admin group is changed from the original:
Tpl/default/Admin/Index/add.html
Changed:
Tpl/default/Admin/Index_add.html
This configuration reduces the directory structure of the template.
Tip: TMPL_FILE_DEPR is also the delimiter between the group language definition and the language file in the language file.
In the above configuration options, to enable grouping, APP_GROUP_LIST must be set. other options are configured according to the actual situation.
Personalized configuration of project groups
If you want to add a personalized configuration for the group project, you can create a directory with the same name as the project group under the configuration directory Conf (the directory naming format is: group name in upper case + other letters in lower case), and define a config. php configuration file. For example, the personal configuration file of the Admin project:
Conf/Admin/config. php
When the config. php file is defined in the group name Directory, the system automatically loads the independent configuration of the group and overwrites the setting of the same options in the public configuration.