ThinkPHP3.2 is used to upgrade thinkphp3.2. ThinkPHP3.2 has updated thinkphp3.2. ThinkPHP3.2 has made many changes based on ThinkPHP3.1. I think this version should be set to ThinkPHP4.0 instead of ThinkPHP 3.2. thinkphp3.2
Preface
ThinkPHP 3.2 has many changes based on ThinkPHP 3.1. I think this version should be set to ThinkPHP 4.0 instead of 3.2. If you are using ThinkPHP 3.1, please do not rush to migrate and upgrade. this is not a simple and safe thing to overwrite files.
1. PHP version
ThinkPHP 3.2 requires PHP 5.3 and later versions, while ThinkPHP 3.1 only requires PHP 5.2.
2. modify the program folder
ThinkPHP 3.2 uses Application as the program folder, while ThinkPHP 3.1 uses app as the program folder.
3. upgrades for different groups
We recommend that you do not group data in future development as much as possible. Otherwise, there will be a lot to deal with for grouping. here we will only introduce ungrouped data. if you have friends who are grouping data, please go to the official documentation to find the answer.
ThinkPHP 3.2 sets a Home directory, and many files will be migrated to the Home directory.
The code is as follows:
App/Common/common. php => Application/Home/Common/function. php
App/Common/extend. php => Application/Home/Common/extend. php (if there is a definition)
App/Conf/Config. php => Application/Home/Conf/config. php
App/Lang/zh-cn/common. php => Application/Home/Lang/zh-cn.php (assuming it exists)
App/Lib/Action => Application/Home/Action
App/Lib/Model => Application/Home/Model
App/Tpl => Application/Home/View
Note that because the Home directory appears, you need to modify your. htaccess file
The code is as follows:
Options + FollowSymlinks
RewriteEngine On
RewriteCond % {REQUEST_FILENAME }! -D
RewriteCond % {REQUEST_FILENAME }! -F
RewriteRule ^ (. *) $ index. php/home/$1 [QSA, PT, L]
Otherwise, the module cannot be found.
The new directory renames Action and Tpl, which are Controller and View respectively. this intuitively reflects the MVC folder deployment method. For those who keep the Action, you can modify the information in Application/Common/config. php:
The code is as follows:
'Default _ C_LAYER '=> 'action', // DEFAULT controller layer name
'Module _ ALLOW_LIST '=> array ('Home', 'admin',...), // Configure your original group list
'Default _ module' => 'home', // Configure your original DEFAULT group
4. changes in system configuration parameters
ThinkPHP 3.2 discards the following system configuration parameters
The code is as follows:
APP_GROUP_LIST
APP_GROUP_MODE
APP_AUTOLOAD_PATH
APP_TAGS_ON
APP_GROUP_PATH
DEFAULT_APP
DEFAULT_GROUP
VAR_GROUP
LOG_DEST
LOG_EXTRA
The following configuration parameters have been modified:
The code is as follows:
DEFAULT_MODULE => DEFAULT_CONTROLLER
5. namespace
ThinkPHP 3.2 adds a namespace and adds the following code to the header of all the files in the Application/Home/Action Directory of the project (the first line except the comments ):
The code is as follows:
Namespace Home \ Action;
Use Think \ Action;
If your project uses controller layering, you need to add similar code to each hierarchical class library file. for example, if you have defined Event layering, you need to add the following code in the header:
The code is as follows:
Namespace Home \ Event;
Use Think \ Action;
Add the following code in the header of all the files under the Application/Home/Model Directory of the project (except for the first line of comments ):
The code is as follows:
Namespace Home \ Model;
Use Think \ Model;
If your project uses model layering, you need to add similar code to each hierarchical class library file. for example, if you have Service layering, you need to add the following code in the header:
The code is as follows:
Namespace Home \ Service;
Use Think \ Model;
6. method adjustment
The following methods of Controller class Think \ Controller or Think \ Action have been abolished:
| Abolition method |
Alternative method |
| _ Get ('id ') |
I ('Get. id ') |
| _ Post ('id ') |
I ('post. id ') |
| _ Put ('id ') |
I ('put. id ') |
| _ Param ('id ') |
I ('id ') |
| _ Request ('id ') |
I ('request. id ') |
| _ Cookie ('id ') |
I ('cookie. id ') |
7. constant adjustment
The following constants have been abolished:
APP_NAME // This constant does not need to be defined in version 3.2.
/Index. php // in version 3.2, _ MODULE _ can be used to indicate the URL address of a MODULE.
GROUP_NAME // in version 3.2, you can use MODULE_NAME to obtain the current module name.
MODE_NAME // in version 3.2, the mode extension has been deprecated. refer to the following mode adjustment section.
In this way, the migration is basically completed. if there are some changes in the process, please go to the official documentation to find the answer.
The above is the ThinkPHP3.2 change described in this article. I hope it will be helpful to you.
Http://www.bkjia.com/PHPjc/963839.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/963839.htmlTechArticleThinkPHP 3.2 version upgrade what content, thinkphp3.2 preface ThinkPHP 3.2 based on ThinkPHP 3.1 on the basis of many changes, I think this version should be set up for ThinkPHP 4.0...