The examples in this article describe the considerations for using thinkphp independent groupings. Share to everyone for your reference. Specific as follows:
About Thinkphp's independent grouping, the function looks very good, but the official does not give the detailed example and the explanation, here, according to the actual development process, gives the PHP developer the following several notes:
1. Separate grouping of directory structures
As with the official instructions, create the Modules folder and configure CONFIG.
Note: The standalone group action is placed directly under the action directory and does not require the Lib directory (this slight difference pits my day)
2. Mutual invocation between separate groupings
If you set up a separate group to deal with the deletion of data, and other methods of grouping calls the method of adding and deleting the group, you will find many miracles, such as a variety of non-existent hints, model validation inexplicable failure and so on, which are due to a reason: no automatic loading of the corresponding module!!
So, give up the official a method and load all the modules yourself, for example:
Copy the Code code as follows: Import (' Action.mcorpworkeraction ', App_path. ' Modules/base ');//action to load the base module yourself
Import (' Model.corpworkermodel ', App_path. ' Modules/base ');
Load the model of the base module yourself, or the methods in the model will be invalidated, etc.
$Mworker = new Mcorpworkeraction (); Instantiate action, pay attention to write it all.
$worker ["LoginName"] =$_request[' loginname '];
$worker ["Realname"] =$_request[' realname '];
$worker ["Pass"] =mmin ($_request[' Pass ');
After you construct the data, add
$r = $Mworker->addfun ($worker);
This will be able to successfully call the base module of the Mcorpworker additions and deletions to change!!
It is hoped that this article will be helpful to everyone's thinkphp framework design.