RC3 version of the major improvements and optimization of the system built middleware, usage and improve some experience, and the less frequently used driving out of the way to provide core extension instead.
The main new features
Increase whereWeek
date inquiry
// 查询本周文章
Article::whereWeek('create_time')->select();
// 查询上周文章
Article::whereWeek('create_time', 'last week')->select();
// 查询2019-1-1到2019-1-7的文章
Article::whereWeek('create_time', '2019-1-1')->select();
Incrementing ID for support Auto Switch
Increment automatically when the acquired ID conversion processing in accordance with the field type of the primary key, rather than the default string type PDO returned.
The current routing rule matching the recording request
Recording the current routing rule object request, by
$request->rule();
Obtaining routing rules that match the actual object for the current request
Increased requireWithout
validation rules
It represents a field when no data must be combined in the form of a complete two fields must be filled in an authentication, for example:
'phone' => 'requireWithout:mobile',
'mobile'=> 'requireWithout:phone',
Ext route optimization method and name and URL generation
Increase custom class project
Canceled built think\Controller
controller base class, the project provides a app\BaseController
controller base class easier to customize.
Further projects also provide app\Request
custom request class, the request may be from the desired properties and methods defined application. It provides app\ExceptionHandle
custom exception class
, easy to customize abnormal takeover process.
URL generation using the object operated
Route class buildUrl
and url
helper function return types to think\route\Url
object instance rather than a string, because the definition of the __toString
method, it can be directly output in the template URL string.
echo url('index/hello',['name'=>'think'])->suffix('htm')->domain('blog');
Modifier improvements
Improved support modifier method does not return any data, but the data is provided directly in the modifier
E.g:
class User extends \think\Model
{
public function setField1Attr($value,$data){
$this->set('field2', $data['field2']);
$this->set('field3', $data['field3']);
}
}
$user = new User;
$user->field1 = 'value1';
$user->save();
When the actual write to the database will not include field1
field data, but will be included field2
and field3
data.
dump
/ halt
Helper function to adjust the output supports a number of variables
you can use
dump($var1,$var2,...)
Mode debugging output multiple variables, the same halt
method can also support output and debug multiple variables stay of execution.
The latest version will be installed in the installation project symfony/var-dumper
expansion to replace the built-in dump
helper functions, so you can be more powerful output
Associated with automatic updates
Associated together
method for automatic update, and delete when you can without usingwith
For example, before writing
$article = Article::with('comments')->find(1);
$article->together(['comments'])->delete();
You can now be written directly
$article = Article::find(1);
$article->together(['comments'])->delete();
Model data set increasing delete
and update
methods
Data sets can batch update and delete operations (support model event)
// 更新今天的数据
$list = Article::whereDay('create_time')->select();
$list->update(['is_new'=>1]);
// 删除昨天的数据
$list = Article::whereDay('create_time', 'yesterday')->select();
$list->delete();
Model supports dynamic switching table and suffixes
<?php
namespace app\model;
use think\Model;
class Blog extends Model
{
// 定义默认的表后缀(默认查询中文数据)
protected $suffix = _cn';
}
Model provides dynamic switching method switch
and setSuffix
, for example:
// switch方法用于静态查询
Blog::switch('_en')->find();
// setSuffix用于动态设置
$blog = new Blog($data);
$blog->setSuffix('_en')->save();
Notes routing support group belongs to a specified route
Routing packets is defined in the annotation, may be used
<?php
namespace app\controller;
/**
* @group('blog')
*/
class Blog
{
/**
* @param string $name 数据名称
* @return mixed
* @route('hello/:name','get')
*/
public function hello($name)
{
return 'hello,'.$name;
}
}
The current controller is automatically added to the route notes blog
grouped below, eventually, will register a blog/hello/:name
routing rule. Like you can set the parameters common to the group routing, for example:
<?php
namespace app\controller;
/**
* @group('blog')->ext('html')
* ->pattern(['id' => '\d+', 'name' => '\w+'])
*
*/
class Blog
{
/**
* @param string $name 数据名称
* @return mixed
* @route('hello/:name','get')
*/
public function hello($name)
{
return 'hello,'.$name;
}
}
If you have already defined in the route definition file blog
grouping can also be added directly to a route the packet, such as:
<?php
namespace app\controller;
class Blog
{
/**
* @param string $name 数据名称
* @return mixed
* @route('hello/:name','get')->group('blog')
*/
public function hello($name)
{
return 'hello,'.$name;
}
}
Multi-language support group definitions
You can use grouping defined in the definition of multi-language time
return [
'user' => [
'welcome' => '欢迎回来',
'login' => '用户登录',
'logout' => '用户登出',
]
];
Then use the following way to obtain multi-language variables
Lang::get('user.login');
lang('user.login');
Support for custom add-language file
It can be extend_list
set, for example:
'extend_list' => [
'zh-cn' => [
app()->getBasePath() . 'lang\zh-cn\app.php',
app()->getBasePath() . 'lang\zh-cn\core.php',
],
]
Facilitate custom language pack in extension
, and now supports the use of language file YML
format definition
Improved cache tag
Increasing the TagSet
class, tag
method support incoming array, while a plurality of tabs for
Cache::tag('tag')->set('name1','value1');
Cache::tag('tag')->set('name2','value2');
// 清除tag标签的缓存数据
Cache::tag('tag')->clear();
And to support the specification of multiple cache tag operation
Cache::tag(['tag1', 'tag2'])->set('name1', 'value1');
Cache::tag(['tag1', 'tag2'])->set('name2', 'value2');
// 清除多个标签的缓存数据
Cache::tag(['tag1','tag2'])->clear();
A cache can be added to the label
Cache::tag('tag')->append('name3');
Increase cache class push
method
Adding elements to an array cache
Cache::set('name', [1,2,3]);
Cache::push('name', 4);
Cache::get('name'); // [1,2,3,4]
Cookie save time support DateTimeInterface
Increase form token middleware
The controller supports __call method
Increase deny_app_list
configuration parameters
You can configure a list of applications prohibit direct access
Controller middleware improvements
Controller middleware only
and except
define case-insensitive
app_map
Pan-mapping application that supports the specified
You may be app_map
defined to resolve the specified application pan configuration application, for example:
'app_map' => [
'think' => 'admin', // 把admin应用映射为think
// ... 其它应用映射定义
'*' => 'home', // 其它应用解析到home
],
Bug fixes
- Precision floating-point correction parameter binding issue
- Correction soft delete
- Correction model database connection
- Correction
RedirectResponse
- Correction Session class
flush
method - JSON field correction parameter binding
- Correction
make:controller
command generation - Correction Cache class
get
method defaults - Corrected binding domain
- Dynamic Correction association model getter
- Correction Model
dateFormat
Properties Methods - Correction url generate support for multiple entries
- Correction ini configuration file format Boolean value problem
- Correction routing latency issues to resolve global configuration invalid
- Amended route cache problems
- Correction related
update
operations - Correction
Relation::$selfRelation
by defaultnull
, resultingRelation::isSelfRelation()
method error - Correcting
redis
cache drive - Smart correction event subscription
observe
methods - Correction field defines the model of the date of issue invalid query
- Correction Console class
getNamespaces
method - Correcting
where
the lack of incoming Query object query method when thebind
data problem - Correction request class
method
method - Correction
route:list
instruction - Correction
Collection
classload
method - Correction
redis
drive port type - Correction
session
data serialization processing problems using JSON - Correction packet routing resolve merge
- The modified model
hidden
method to hide problems associated with model - Correction associated with the query associated with key empty error
- Fixed 204 returns a response status code is determined
- Amendments
Request
classhas
methodsenv
andsession
support - Correction
provider.php
file is invalid problem - Correcting some of the problems associated with the query
- Correction validate helper function that supports the specified validator class
- Correcting validation class
getValidateType
method - To open a separate entrance amendments debugging mode
- Composer application load correction
Usage adjustment
- Page
trace
middleware valid only in debug mode
, and without setting environment variables Socket
Log drive out of the corePostgreSQL
,Sqlite
AndSqlServer
driven out of the core, instead extended- Cancel built
think\Controller
the base class Yaconf
Out of the core into the support extendedthink-yaconf
- Fields changed to exclude
withoutField
methods - Cancel
useGlobalScope
method for increasingwithoutGlobalScope
method - Change the default location of the generated middleware
- Load default language packs without opening multiple languages Middleware
Cookie
Class recoveryget
andhas
methods supporttoken
Helper function adjustment- Caching global request parameter adjustment
- Unified middleware call parameter passing, do not support the
:
split of mass participation - Unified cache data serialized after storage
Abandoned usage
- Cancel multilingual
auto_detect
configuration - Cancel
session
classauto_start
configuration parameters andboot
methods - Abandoned
Where
array object query - Cancellation observer model events
- Cancellation
JumpResponse
andsuccess
/error
/result
other methods and helper - Cancel query expression parsing and extended
think\db\Expression
class - Abandoned model AutoComplete feature, use an alternative model events
- Cancellation
cookie
ofprefix
parameters - Cancel a series of helper functions deprecated
- Cancel
optimize:facade
optimize:model
instruction was changed to expansion mode - Cancel command line URL
- Delete
Config
classes__get
and__isset
methods