Changes in thinkphp 3.2

Source: Internet
Author: User

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.

App/Common/common.php         =>     Application/Home/Common/function.phpApp/Common/extend.php         =>     Application/Home/Common/extend.php(假设存在定义的话)App/Conf/Config.php           =>     Application/Home/Conf/config.phpApp/Lang/zh-cn/common.php     =>     Application/Home/Lang/zh-cn.php(假设存在的话)App/Lib/Action     =>    Application/Home/ActionApp/Lib/Model      =>    Application/Home/ModelApp/Tpl             =>  Application/Home/View

Note that because the Home directory appears, you need to modify your. htaccess file to

<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 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:

‘DEFAULT_C_LAYER‘       =>  ‘Action‘, // 默认的控制器层名称‘MODULE_ALLOW_LIST‘     =>  array(‘Home‘,‘Admin‘,...), // 配置你原来的分组列表‘DEFAULT_MODULE‘        =>  ‘Home‘, // 配置你原来的默认分组
4. Changes in System configuration parameters

Thinkphp 3.2 Deprecated The following system configuration parameters

APP_GROUP_LISTAPP_GROUP_MODEAPP_AUTOLOAD_PATHAPP_TAGS_ONAPP_GROUP_PATHDEFAULT_APPDEFAULT_GROUPVAR_GROUPLOG_DESTLOG_EXTRA

The following configuration parameters have been modified

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):

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:

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):

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:

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:

APP_NAME // 3.2版本中无需再定义该常量  __GROUP__ // 3.2版本中可以用__MODULE__ 表示模块的URL地址  GROUP_NAME //3.2版本中可以用 MODULE_NAME 获取当前模块名  MODE_NAME  // 3.2版本中模式扩展已经废弃,参考下面的模式调整部分  

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

Changes in thinkphp 3.2

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.