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, language packs, and other project groups.
The project group is ThinkPHP.
An important mechanism is that the project grouping function can combine multiple projects in the past into one project, which can be reused for 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: an example or suggestion of configuration options
- APP_GROUP_LIST: list of all group names. If this parameter is not set, the project group mode 'app _ GROUP_LIST '=> 'Home, Admin, User, Blog' is disabled ',
- The DEFAULT project GROUP name of DEFAULT_GROUP. the DEFAULT value is Home 'default _ group' => 'home ',
- The delimiter between APP_GROUP_DEPR project groups. the default delimiter is. (point). it is used to separate function A and routing configuration. the default delimiter is recommended.
- The delimiter between modules and operations in the TMPL_FILE_DEPR template file. the default delimiter is/. it is only valid for project group deployment. the default delimiter is recommended. you can use the U method to automatically generate a URL.
- VAR_GROUP: variable used to obtain 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 Index module is grouped by Admin.
Add
For the operation, the corresponding template file 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
It is also the delimiter between the group language definition in the language file and the language file.
In the above configuration options, to enable grouping, APP_GROUP_LIST
It 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 team (the directory naming format is: group name in upper case letters + other letters in lower case), and define a config. php configuration file in the directory. For example, Admin
Personalized configuration file of the project:
Conf/Admin/config. php
When config. php is defined in the group name Directory
When you access this group, the system automatically loads the independent configuration of the group and overwrites the setting of the same options in the public configuration.
Read more
ThinkPHP system configuration