The examples in this article describe the considerations for using thinkphp separate groupings. Share to everyone for your reference. Specifically as follows:
About thinkphp 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 instructions:
1. Directory structure of separate groupings
As with official instructions, set up the Modules folder and configure CONFIG.
Note: The separate group action is placed directly under the action directory, and no Lib directory is required (this slight difference pits me one day)
2. Mutual invocation between independent groupings
If you set up an independent group that specializes in data deletion, change and check, other grouping methods call this group of additions and deletions to check the method, you will find many miracles, such as a variety of non-existent hints, model validation inexplicable failure and so on, which is due to a reason: not automatically load the corresponding module!!
So, give up the official a method and load all the modules yourself, for example:
Copy Code code as follows:
Import (' Action.mcorpworkeraction ', App_path. ' Modules/base ');//Load the action of the Base module yourself
Import (' Model.corpworkermodel ', App_path. ' Modules/base ');
You load the base module model, or automatic verification and so on model method will fail
$Mworker = new Mcorpworkeraction (); Instantiate action, pay attention to write it all
$worker ["LoginName"] =$_request[' loginname '];
$worker ["Realname"] =$_request[' realname '];
$worker ["Pass"] =mmin ($_request[' Pass ']);
Add after constructing data
$r = $Mworker->addfun ($worker);
In order to successfully invoke the base module of the Mcorpworker to check and delete!!
I hope this article will be helpful to everyone's thinkphp framework program design.