What thinkphp version 3.2 has upgraded

Source: Internet
Author: User
Tags constant extend

Thinkphp 3.2 has been released for a long time, and here's a summary of what happened to thinkphp 3.2 to make it easier for programmers to develop.

-->

Objective

Thinkphp 3.2 is based on thinkphp 3.1, and I think this version should be set to thinkphp 4.0 instead of 3.2. If you are using thinkphp 3.1 do not rush to migrate upgrades, this is not a simple overwrite the file on the safe and sound things.

1. PHP version

Thinkphp 3.2 requires more than 5.3 versions of PHP, and thinkphp 3.1 only needs PHP 5.2.

2. Modify the program folder

Thinkphp 3.2 uses application as the program folder, and Thinkphp 3.1 is using app as the program file.

3. Different group set up the upgrade

It is recommended that future development as far as possible not to do grouping, or for groups, there are a lot to deal with the place, here is just to introduce the situation of the group, have to do group friends, please go to the official document to find the answer.

Thinkphp 3.2 Sets a home directory, and many files are 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 (assuming existence defined)
app/conf/config.php => application/home/conf/config.php
app/lang/zh-cn/common.php => application/home/lang/zh-cn.php (if present)
App/lib/action => application/home/action
App/lib/model => Application/home/model
APP/TPL => Application/home/view

Note that because of the presence of the home directory, you need to modify your. htaccess file to

The code is as follows:
<ifmodule mod_rewrite.c>
Options +followsymlinks
Rewriteengine on
Rewritecond%{request_filename}!-d
Rewritecond%{request_filename}!-f
Rewriterule ^ (. *) $ index.php/home/$1 [qsa,pt,l]
</IfModule>

Otherwise, there will be an error that the module cannot find.

The new directory renames the Action and TPL, respectively, Controller and View, which is a more intuitive embodiment of how the MVC folder is deployed. For those friends who keep the Action, you can modify the information in the 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 grouped 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. Namespaces

Thinkphp 3.2 Adds a namespace and adds the following code (must be the first line except the annotation) to all files under the Application/home/action directory of the project:

The code is as follows:
namespace Homeaction;
Use thinkaction;

If your project uses a controller hierarchy, you need to add similar code to each layered class library file, such as defining an event hierarchy, which needs to be added in the header:

The code is as follows:
namespace Homeevent;
Use thinkaction;

Add the following code (must be the first line in addition to the annotation) to all files below the Application/home/model directory of the project:

The code is as follows:
namespace Homemodel;
Use Thinkmodel;

If your project uses model tiering, you need to add similar code to each layered class library file, such as if you have a service hierarchy that needs to be added in the header:

The code is as follows:
namespace Homeservice;
Use Thinkmodel;

6. Method adjustment

The following methods for controller class Thinkcontroller or thinkaction have been abolished:

Repeal Method Alternative Methods
_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:
No further definition of the constant in the App_name//3.2 version
__GROUP__//3.2 can be used to represent the URL address of the module in __module__
Group_name//3.2 version can get the current module name with Module_name
The schema extension has been deprecated in the Mode_name//3.2 version, referring to the following Pattern tuning section

This basically completes the migration, if there are some changes in the middle, please go to the official document to find the answer.

These are the changes that have been described in this article about ThinkPHP3.2, and I hope that we can help.

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.