In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "what is the difference between thinkphp3.2 and thinkphp5.0". In daily operation, I believe many people have doubts about what is the difference between thinkphp3.2 and thinkphp5.0. Xiaobian consulted various materials and sorted out simple and easy operation methods. I hope to help you answer the doubts about "what is the difference between thinkphp3.2 and thinkphp5.0"! Next, please follow the small series to learn together!
Differences: 1. 3.2 supports common URL patterns and regular route definitions, but 5.0 does not;2. 5.0 adds request objects and response objects;3. 5.0 has zero tolerance for errors, but 3.2 does not;4. 5.0 discards most of the original constant definitions, and only retains the path constant definitions of the framework.
This tutorial operates on Windows 7, thinkphp v5.0, Dell G3 computers.
Difference Between ThinkPHP 5.0 and ThinkPHP 3.2
5.0 There are significant differences between version 3.2 and previous versions, and this article shows some of the major differences between version 5.0 and version 3.2.
URLs and Routes
5.0 URL access no longer supports ordinary URL patterns, and routes do not support regular route definitions, but are all changed to regular routes with variable rules (regular definitions):
The main improvements are as follows;
Add routing variable rules;
Added composite variable support;
Add resource routing;
Add routing packets;
Added closure definition support;
Added MISS routing definition;
Support URL routing rule resolution;
Request object and response object
5.0 Request object and Response object are added. Request processes request and obtains request information uniformly, and Response object is responsible for outputting client or browser response.
module and a controller
The controller namespace has been tweaked and no controller classes need to be inherited.
Application namespaces are unified as apps (definable) rather than module names;
Controller class name does not have Controller suffix by default. You can configure to enable use_controller_suffix parameter to enable controller class suffix;
The controller operation method uses return mode to return data instead of direct output;
Abolish the original operation before and after the method;
Add beforeActionList attribute to define the preceding operation;
Support arbitrary level controller definition and access;
URL access supports automatic location controller;
database
5.0 The database query function of is enhanced. The chain query that originally needs to be used through the model can be called directly through the Db class. The original M function call can be changed to db function, for example:
3.2 version
M('User')->where(['name'=>'thinkphp'])->find();
5.0 version
db('User')->where('name','thinkphp')->find();
The main improvements are as follows:
Support chain query operation;
Data queries support return objects, arrays, and PDOStatement objects;
DataSet queries support returning arrays and Collection objects;
Query constructor added, query syntax changed;
Support closure queries;
Support block query;
Support view query;
Add SQL listening events;
model
5.0 The model change is the biggest, basically the model is a completely object-oriented concept, including the associated model, the suffix of the model class is no longer Model, directly distinguished by the namespace, the original D function call is changed to the model function, and the corresponding model class must be created, for example:
3.2 version
D('User')->where(['name'=>'thinkphp'])->find();
5.0 version
model('User')->where('name','thinkphp')->find();
Major improvements include:
Reconstructing the association model;
Support aggregation models;
Abolish view model (change to database view query method);
Trait mechanism is adopted to extend the model.
Add fetchers and modifiers;
Add automatic timestamp writing;
Added type field conversion;
Array access support;
JSON serialization support;
Auto-verification and auto-completion
5.0 Data validation and auto-completion in version 5.0 are quite different from those in version 3.2. Data validation in version 5.0 adopts validator definition and unified validation through the think\Validate class. Autocomplete is accomplished by defining modifiers in the model.
abnormal
5.0 Zero tolerance for errors, throws exceptions for any level of error by default (but error levels can be set in the app common file), and redesigned exception pages to show detailed error messages for debugging.
Debugging and logging
5.0 Trace page enhancement, support browser console to view Trace information.
5.0 SocketLog is used to support Remote Debugging.
constant
5.0 The version discards most of the original constant definitions, only retains the path constant definitions of the framework, and the rest of the constants can be completed by using the relevant properties or methods of the App class or the Request class, or redefine the required constants.
Repealed constants include:
REQUEST_METHOD IS_GET IS_POST IS_PUT IS_DELETE IS_AJAX __EXT__ COMMON_MODULE MODULE_NAME CONTROLLER_NAME ACTION_NAME APP_NAMESPACE APP_DEBUG MODULE_PATH
function
5.0 The core framework does not rely on any custom functions, but still encapsulates some common functions into helper functions, which you can redefine or add at will.
At this point, the study of "what is the difference between thinkphp3.2 and thinkphp5.0" is over, hoping to solve everyone's doubts. Theory and practice can better match to help you learn, go and try it! If you want to continue learning more relevant knowledge, please continue to pay attention to the website, Xiaobian will continue to strive to bring more practical articles for everyone!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.