thinkphp what is upgraded in version 3.2 _php tutorial

Source: Internet
Author: User

What thinkphp version 3.2 has upgraded


Thinkphp 3.2 has been released for a long time, and here is also a summary of the thinkphp 3.2 what happened in the end of the changes to facilitate the development of programmers.

Objective

Thinkphp 3.2 Based on thinkphp 3.1 has a lot of changes, I think this version should be set up for thinkphp 4.0 instead of what 3.2. If you are using thinkphp 3.1 do not rush to migrate the upgrade, this is not easy to cover the file on the safe thing.

1. Version of PHP

Thinkphp 3.2 requires PHP 5.3 or higher, and thinkphp 3.1 requires PHP 5.2.

2. Changes to program folders

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

3. Upgrade of different group settings

Recommended later development try not to do grouping, or for groups, there are a lot of places to deal with, here is just the case of non-grouping, there are groups of friends, please on the official documents to find answers.

Thinkphp 3.2 sets up 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 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 (if present)
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 to

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, there will be errors that the module cannot find.

The new catalog has renamed Action and TPL, Controller and View, to provide a more intuitive representation of how MVC's folders are deployed. For those friends who have retained 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 group list
' Default_module ' = ' Home ',//Configure your original default grouping



4. Changes in System configuration parameters

Thinkphp 3.2 Deprecated 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, adds the following code to the header of all files under the Application/home/action directory of the project (must be the first line except for the comment):

The code is as follows:


namespace Home\action;
Use think\action;

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 you need to add to your head:

The code is as follows:


namespace Home\event;
Use think\action;

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

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 layered class library file, for example, if you have a service hierarchy, you need to add it to your head:

The code is as follows:


namespace Home\service;
Use Think\model;



6. Method adjustment

The following methods of the Controller class Think\controller or think\action 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 need to define this constant in App_name//3.2 version
__GROUP__//Version 3.2 can be used __module__ to represent the URL address of the module
Group_name//3.2 version can get the current module name with Module_name
Schema extension deprecated in Mode_name//3.2 version, refer to the following Mode adjustment section

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

The above is the change of the ThinkPHP3.2 in this article, and I hope that we can have some help.

http://www.bkjia.com/PHPjc/963995.html www.bkjia.com true http://www.bkjia.com/PHPjc/963995.html techarticle thinkphp 3.2 Version of what has been upgraded thinkphp 3.2 has been released for a long time, and here also summarizes what happened to thinkphp 3.2, which makes it easy for programmers to develop. Before ...

  • 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.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.