Skip to content

Commit

Permalink
Merge branch '5.1' of https://git.topthink.com/topteam/framework into…
Browse files Browse the repository at this point in the history
… 5.1
  • Loading branch information
liu21st committed Apr 28, 2017
2 parents 2c0e33b + aba0802 commit f6db572
Show file tree
Hide file tree
Showing 70 changed files with 5,787 additions and 5,073 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
ThinkPHP 5.1Alpha
ThinkPHP 5.1Beta
===============

ThinkPHP5.1对底层架构做了进一步的改进,减少依赖,其主要特性包括:

+ 采用容器统一管理对象
+ 支持Facade
+ 更易用的路由
+ 配置和路由目录独立
+ 取消系统常量
+ 助手函数增强
+ 类库别名机制
+ 模型和数据库增强
+ 依赖注入完善

计划下一版废除的功能
废除的功能

+ 聚合模型
+ Rest控制器扩展类
+ 内置控制器扩展类

> ThinkPHP5的运行环境要求PHP5.6以上。
Expand Down Expand Up @@ -93,13 +94,16 @@ www WEB部署目录(或者子目录)
## 升级指导

应用类库的命名空间app如果需要更改,设置app_namespace环境变量

取消命名空间的别名功能,原有下面系统类库的命名空间需要调整:

* think\App => think\facade\App (或者 App )
* think\Cache => think\facade\Cache (或者 Cache )
* think\Config => think\facade\Config (或者 Config )
* think\Cookie => think\facade\Cookie (或者 Cookie )
* think\Debug => think\facade\Debug (或者 Debug )
* think\Env => think\facade\Env (或者 Env )
* think\Hook => think\facade\Hook (或者 Hook )
* think\Lang => think\facade\Lang (或者 Lang )
* think\Log => think\facade\Log (或者 Log )
Expand All @@ -115,7 +119,11 @@ www WEB部署目录(或者子目录)

取消Loader::import方法以及import和vendor助手函数
原来Loader类的controller、model、action和validate方法改为App类的同名方法

模型的数据集查询始终返回数据集对象而不是数组
模型的数据表主键如果不是id 需要设置模型的pk属性
路由的before_behavior和after_behavior参数更改为before和after
路由缓存功能暂时取消
软删除trait引入更改为 think\model\concern\SoftDelete

## 命名规范

Expand Down
5 changes: 4 additions & 1 deletion base.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ interface LoggerInterface
'config' => Config::class,
'cookie' => Cookie::class,
'debug' => Debug::class,
'env' => Env::class,
'hook' => Hook::class,
'lang' => Lang::class,
'log' => Log::class,
Expand All @@ -45,6 +46,7 @@ interface LoggerInterface
'session' => Session::class,
'url' => Url::class,
'view' => View::class,

// 接口依赖注入
'think\LoggerInterface' => Log::class,
]);
Expand All @@ -57,6 +59,7 @@ interface LoggerInterface
facade\Config::class => Config::class,
facade\Cookie::class => Cookie::class,
facade\Debug::class => Debug::class,
facade\Env::class => Env::class,
facade\Hook::class => Hook::class,
facade\Lang::class => Lang::class,
facade\Log::class => Log::class,
Expand All @@ -77,7 +80,7 @@ interface LoggerInterface
'Cookie' => facade\Cookie::class,
'Db' => Db::class,
'Debug' => facade\Debug::class,
'Env' => Env::class,
'Env' => facade\Env::class,
'Facade' => Facade::class,
'Hook' => facade\Hook::class,
'Lang' => facade\Lang::class,
Expand Down
27 changes: 26 additions & 1 deletion helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@
use think\facade\Url;
use think\Response;

if (!function_exists('container')) {
/**
* 获取容器对象实例
* @return Container
*/
function container()
{
return Container::getInstance();
}
}

if (!function_exists('app')) {
/**
* 快速获取容器中的实例 支持依赖注入
Expand All @@ -41,11 +52,25 @@ function app($name = 'think\App', $args = [])
}
}

if (!function_exists('bind')) {
/**
* 绑定一个类到容器
* @access public
* @param string $abstract 类标识、接口
* @param mixed $concrete 要绑定的类、闭包或者实例
* @return Container
*/
function bind($abstract, $concrete = null)
{
return Container::getInstance()->bind($abstract, $concrete);
}
}

if (!function_exists('call')) {
/**
* 调用反射执行callable 支持依赖注入
* @param mixed $callable 支持闭包等callable写法
* @param array $args 变量
* @param array $args 参数
* @return mixed
*/
function call($callable, $args = [])
Expand Down

0 comments on commit f6db572

Please sign in to comment.