mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 07:32:48 +08:00
增加接口类 规范驱动扩展
This commit is contained in:
2
library/think/cache/driver/Apc.php
vendored
2
library/think/cache/driver/Apc.php
vendored
@@ -18,7 +18,7 @@ use think\Exception;
|
|||||||
* Apc缓存驱动
|
* Apc缓存驱动
|
||||||
* @author liu21st <liu21st@gmail.com>
|
* @author liu21st <liu21st@gmail.com>
|
||||||
*/
|
*/
|
||||||
class Apc
|
class Apc implements CacheInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $options = [
|
protected $options = [
|
||||||
|
|||||||
50
library/think/cache/driver/CacheInterface.php
vendored
Normal file
50
library/think/cache/driver/CacheInterface.php
vendored
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace think\cache\driver;
|
||||||
|
|
||||||
|
interface CacheInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取缓存
|
||||||
|
* @access public
|
||||||
|
* @param string $name 缓存变量名
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function get($name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写入缓存
|
||||||
|
* @access public
|
||||||
|
* @param string $name 缓存变量名
|
||||||
|
* @param mixed $value 存储数据
|
||||||
|
* @param int $expire 有效时间 0为永久
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function set($name, $value, $expire = null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除缓存
|
||||||
|
* @access public
|
||||||
|
* @param string $name 缓存变量名
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function rm($name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清除缓存
|
||||||
|
* @access public
|
||||||
|
* @return boolean
|
||||||
|
*/
|
||||||
|
public function clear();
|
||||||
|
|
||||||
|
}
|
||||||
26
library/think/cache/driver/Db.php
vendored
26
library/think/cache/driver/Db.php
vendored
@@ -24,23 +24,23 @@ use think\Cache;
|
|||||||
* );
|
* );
|
||||||
* @author liu21st <liu21st@gmail.com>
|
* @author liu21st <liu21st@gmail.com>
|
||||||
*/
|
*/
|
||||||
class Db
|
class Db implements CacheInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $handler = null;
|
protected $handler = null;
|
||||||
protected $options = [
|
protected $options = [
|
||||||
'type' => '',
|
'type' => '',
|
||||||
'dsn' => '',
|
'dsn' => '',
|
||||||
'hostname' => '',
|
'hostname' => '',
|
||||||
'hostport' => '',
|
'hostport' => '',
|
||||||
'username' => '',
|
'username' => '',
|
||||||
'password' => '',
|
'password' => '',
|
||||||
'database' => '',
|
'database' => '',
|
||||||
'charset' => '',
|
'charset' => '',
|
||||||
'table' => '',
|
'table' => '',
|
||||||
'prefix' => '',
|
'prefix' => '',
|
||||||
'expire' => 0,
|
'expire' => 0,
|
||||||
'length' => 0,
|
'length' => 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
4
library/think/cache/driver/File.php
vendored
4
library/think/cache/driver/File.php
vendored
@@ -17,7 +17,7 @@ use think\Cache;
|
|||||||
* 文件类型缓存类
|
* 文件类型缓存类
|
||||||
* @author liu21st <liu21st@gmail.com>
|
* @author liu21st <liu21st@gmail.com>
|
||||||
*/
|
*/
|
||||||
class File
|
class File implements CacheInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $options = [
|
protected $options = [
|
||||||
@@ -186,7 +186,7 @@ class File
|
|||||||
*/
|
*/
|
||||||
public function clear()
|
public function clear()
|
||||||
{
|
{
|
||||||
$fileLsit = (array)glob($this->options['path'].'*');
|
$fileLsit = (array) glob($this->options['path'] . '*');
|
||||||
foreach ($fileLsit as $path) {
|
foreach ($fileLsit as $path) {
|
||||||
is_file($path) && unlink($path);
|
is_file($path) && unlink($path);
|
||||||
}
|
}
|
||||||
|
|||||||
2
library/think/cache/driver/Lite.php
vendored
2
library/think/cache/driver/Lite.php
vendored
@@ -17,7 +17,7 @@ use think\Cache;
|
|||||||
* 文件类型缓存类
|
* 文件类型缓存类
|
||||||
* @author liu21st <liu21st@gmail.com>
|
* @author liu21st <liu21st@gmail.com>
|
||||||
*/
|
*/
|
||||||
class Lite
|
class Lite implements CacheInterface
|
||||||
{
|
{
|
||||||
protected $options = [
|
protected $options = [
|
||||||
'prefix' => '',
|
'prefix' => '',
|
||||||
|
|||||||
2
library/think/cache/driver/Memcache.php
vendored
2
library/think/cache/driver/Memcache.php
vendored
@@ -14,7 +14,7 @@ namespace think\cache\driver;
|
|||||||
use think\Cache;
|
use think\Cache;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
|
|
||||||
class Memcache
|
class Memcache implements CacheInterface
|
||||||
{
|
{
|
||||||
protected $handler = null;
|
protected $handler = null;
|
||||||
protected $options = [
|
protected $options = [
|
||||||
|
|||||||
2
library/think/cache/driver/Memcached.php
vendored
2
library/think/cache/driver/Memcached.php
vendored
@@ -14,7 +14,7 @@ namespace think\cache\driver;
|
|||||||
use think\Cache;
|
use think\Cache;
|
||||||
use think\Exception;
|
use think\Exception;
|
||||||
|
|
||||||
class Memcached
|
class Memcached implements CacheInterface
|
||||||
{
|
{
|
||||||
protected $handler = null;
|
protected $handler = null;
|
||||||
protected $options = [
|
protected $options = [
|
||||||
|
|||||||
10
library/think/cache/driver/Redis.php
vendored
10
library/think/cache/driver/Redis.php
vendored
@@ -19,7 +19,7 @@ use think\Exception;
|
|||||||
* 要求安装phpredis扩展:https://github.com/nicolasff/phpredis
|
* 要求安装phpredis扩展:https://github.com/nicolasff/phpredis
|
||||||
* @author 尘缘 <130775@qq.com>
|
* @author 尘缘 <130775@qq.com>
|
||||||
*/
|
*/
|
||||||
class Redis
|
class Redis implements CacheInterface
|
||||||
{
|
{
|
||||||
protected $handler = null;
|
protected $handler = null;
|
||||||
protected $options = [
|
protected $options = [
|
||||||
@@ -65,10 +65,10 @@ class Redis
|
|||||||
public function get($name)
|
public function get($name)
|
||||||
{
|
{
|
||||||
Cache::$readTimes++;
|
Cache::$readTimes++;
|
||||||
$value = $this->handler->get($this->options['prefix'] . $name);
|
$value = $this->handler->get($this->options['prefix'] . $name);
|
||||||
$jsonData = json_decode( $value, true );
|
$jsonData = json_decode($value, true);
|
||||||
// 检测是否为JSON数据 true 返回JSON解析数组, false返回源数据 byron sampson<xiaobo.sun@qq.com>
|
// 检测是否为JSON数据 true 返回JSON解析数组, false返回源数据 byron sampson<xiaobo.sun@qq.com>
|
||||||
return ($jsonData === null) ? $value : $jsonData;
|
return (null === $jsonData) ? $value : $jsonData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,7 +87,7 @@ class Redis
|
|||||||
}
|
}
|
||||||
$name = $this->options['prefix'] . $name;
|
$name = $this->options['prefix'] . $name;
|
||||||
//对数组/对象数据进行缓存处理,保证数据完整性 byron sampson<xiaobo.sun@qq.com>
|
//对数组/对象数据进行缓存处理,保证数据完整性 byron sampson<xiaobo.sun@qq.com>
|
||||||
$value = (is_object($value) || is_array($value)) ? json_encode($value) : $value;
|
$value = (is_object($value) || is_array($value)) ? json_encode($value) : $value;
|
||||||
if (is_int($expire)) {
|
if (is_int($expire)) {
|
||||||
$result = $this->handler->setex($name, $expire, $value);
|
$result = $this->handler->setex($name, $expire, $value);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
2
library/think/cache/driver/Sae.php
vendored
2
library/think/cache/driver/Sae.php
vendored
@@ -18,7 +18,7 @@ use think\Exception;
|
|||||||
* SAE Memcache缓存驱动
|
* SAE Memcache缓存驱动
|
||||||
* @author liu21st <liu21st@gmail.com>
|
* @author liu21st <liu21st@gmail.com>
|
||||||
*/
|
*/
|
||||||
class Sae
|
class Sae implements CacheInterface
|
||||||
{
|
{
|
||||||
protected $handler = null;
|
protected $handler = null;
|
||||||
protected $options = [
|
protected $options = [
|
||||||
|
|||||||
2
library/think/cache/driver/Secache.php
vendored
2
library/think/cache/driver/Secache.php
vendored
@@ -17,7 +17,7 @@ use think\Cache;
|
|||||||
* Secache缓存驱动
|
* Secache缓存驱动
|
||||||
* @author liu21st <liu21st@gmail.com>
|
* @author liu21st <liu21st@gmail.com>
|
||||||
*/
|
*/
|
||||||
class Secache
|
class Secache implements CacheInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $handler = null;
|
protected $handler = null;
|
||||||
|
|||||||
2
library/think/cache/driver/Sqlite.php
vendored
2
library/think/cache/driver/Sqlite.php
vendored
@@ -18,7 +18,7 @@ use think\Exception;
|
|||||||
* Sqlite缓存驱动
|
* Sqlite缓存驱动
|
||||||
* @author liu21st <liu21st@gmail.com>
|
* @author liu21st <liu21st@gmail.com>
|
||||||
*/
|
*/
|
||||||
class Sqlite
|
class Sqlite implements CacheInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $options = [
|
protected $options = [
|
||||||
|
|||||||
2
library/think/cache/driver/Test.php
vendored
2
library/think/cache/driver/Test.php
vendored
@@ -17,7 +17,7 @@ use think\Cache;
|
|||||||
* 测试缓存类
|
* 测试缓存类
|
||||||
* @author liu21st <liu21st@gmail.com>
|
* @author liu21st <liu21st@gmail.com>
|
||||||
*/
|
*/
|
||||||
class Test
|
class Test implements CacheInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
2
library/think/cache/driver/Wincache.php
vendored
2
library/think/cache/driver/Wincache.php
vendored
@@ -18,7 +18,7 @@ use think\Exception;
|
|||||||
* Wincache缓存驱动
|
* Wincache缓存驱动
|
||||||
* @author liu21st <liu21st@gmail.com>
|
* @author liu21st <liu21st@gmail.com>
|
||||||
*/
|
*/
|
||||||
class Wincache
|
class Wincache implements CacheInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $options = [
|
protected $options = [
|
||||||
|
|||||||
2
library/think/cache/driver/Xcache.php
vendored
2
library/think/cache/driver/Xcache.php
vendored
@@ -18,7 +18,7 @@ use think\Exception;
|
|||||||
* Xcache缓存驱动
|
* Xcache缓存驱动
|
||||||
* @author liu21st <liu21st@gmail.com>
|
* @author liu21st <liu21st@gmail.com>
|
||||||
*/
|
*/
|
||||||
class Xcache
|
class Xcache implements CacheInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
protected $options = [
|
protected $options = [
|
||||||
|
|||||||
25
library/think/config/driver/ConfigInterface.php
Normal file
25
library/think/config/driver/ConfigInterface.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace think\config\driver;
|
||||||
|
|
||||||
|
interface ConfigInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 解析配置
|
||||||
|
* @access public
|
||||||
|
* @param mixed $config 配置
|
||||||
|
* @return mixed
|
||||||
|
*/
|
||||||
|
public function parse($config);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace think\config\driver;
|
namespace think\config\driver;
|
||||||
|
|
||||||
class Ini
|
class Ini implements ConfigInterface
|
||||||
{
|
{
|
||||||
public function parse($config)
|
public function parse($config)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace think\config\driver;
|
namespace think\config\driver;
|
||||||
|
|
||||||
class Xml
|
class Xml implements ConfigInterface
|
||||||
{
|
{
|
||||||
public function parse($config)
|
public function parse($config)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ use think\exception\DbBindParamException;
|
|||||||
use think\exception\PDOException;
|
use think\exception\PDOException;
|
||||||
use think\Log;
|
use think\Log;
|
||||||
|
|
||||||
abstract class Connection
|
abstract class Connection implements ConnectionInterface
|
||||||
{
|
{
|
||||||
// PDO操作实例
|
// PDO操作实例
|
||||||
protected $PDOStatement;
|
protected $PDOStatement;
|
||||||
@@ -226,14 +226,6 @@ abstract class Connection
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 解析pdo连接的dsn信息(由驱动扩展)
|
|
||||||
* @access public
|
|
||||||
* @param array $config 连接信息
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
abstract protected function parseDsn($config);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 释放查询结果
|
* 释放查询结果
|
||||||
* @access public
|
* @access public
|
||||||
|
|||||||
47
library/think/db/ConnectionInterface.php
Normal file
47
library/think/db/ConnectionInterface.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace think\db;
|
||||||
|
|
||||||
|
interface ConnectionInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 解析pdo连接的dsn信息
|
||||||
|
* @access public
|
||||||
|
* @param array $config 连接信息
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function parseDsn($config);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得数据表的字段信息
|
||||||
|
* @access public
|
||||||
|
* @param string $tableName
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getFields($tableName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 取得数据库的表信息
|
||||||
|
* @access public
|
||||||
|
* @param string $dbName
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getTables($dbName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* SQL性能分析
|
||||||
|
* @access protected
|
||||||
|
* @param string $sql
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function getExplain($sql);
|
||||||
|
}
|
||||||
@@ -26,7 +26,7 @@ class Mysql extends Connection
|
|||||||
* @param array $config 连接信息
|
* @param array $config 连接信息
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseDsn($config)
|
public function parseDsn($config)
|
||||||
{
|
{
|
||||||
$dsn = 'mysql:dbname=' . $config['database'] . ';host=' . $config['hostname'];
|
$dsn = 'mysql:dbname=' . $config['database'] . ';host=' . $config['hostname'];
|
||||||
if (!empty($config['hostport'])) {
|
if (!empty($config['hostport'])) {
|
||||||
@@ -91,11 +91,11 @@ class Mysql extends Connection
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL性能分析
|
* SQL性能分析
|
||||||
* @access protected
|
* @access public
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getExplain($sql)
|
public function getExplain($sql)
|
||||||
{
|
{
|
||||||
$pdo = $this->linkID->query("EXPLAIN " . $sql);
|
$pdo = $this->linkID->query("EXPLAIN " . $sql);
|
||||||
$result = $pdo->fetch(\PDO::FETCH_ASSOC);
|
$result = $pdo->fetch(\PDO::FETCH_ASSOC);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class Oracle extends Connection
|
|||||||
* @param array $config 连接信息
|
* @param array $config 连接信息
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseDsn($config)
|
public function parseDsn($config)
|
||||||
{
|
{
|
||||||
$dsn = 'oci:dbname=';
|
$dsn = 'oci:dbname=';
|
||||||
if (!empty($config['hostname'])) {
|
if (!empty($config['hostname'])) {
|
||||||
@@ -139,11 +139,11 @@ class Oracle extends Connection
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL性能分析
|
* SQL性能分析
|
||||||
* @access protected
|
* @access public
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getExplain($sql)
|
public function getExplain($sql)
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class Pgsql extends Connection
|
|||||||
* @param array $config 连接信息
|
* @param array $config 连接信息
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseDsn($config)
|
public function parseDsn($config)
|
||||||
{
|
{
|
||||||
$dsn = 'pgsql:dbname=' . $config['database'] . ';host=' . $config['hostname'];
|
$dsn = 'pgsql:dbname=' . $config['database'] . ';host=' . $config['hostname'];
|
||||||
if (!empty($config['hostport'])) {
|
if (!empty($config['hostport'])) {
|
||||||
@@ -79,11 +79,11 @@ class Pgsql extends Connection
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL性能分析
|
* SQL性能分析
|
||||||
* @access protected
|
* @access public
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getExplain($sql)
|
public function getExplain($sql)
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ class Sqlite extends Connection
|
|||||||
* @param array $config 连接信息
|
* @param array $config 连接信息
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseDsn($config)
|
public function parseDsn($config)
|
||||||
{
|
{
|
||||||
$dsn = 'sqlite:' . $config['database'];
|
$dsn = 'sqlite:' . $config['database'];
|
||||||
return $dsn;
|
return $dsn;
|
||||||
@@ -78,11 +78,11 @@ class Sqlite extends Connection
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL性能分析
|
* SQL性能分析
|
||||||
* @access protected
|
* @access public
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getExplain($sql)
|
public function getExplain($sql)
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ class Sqlsrv extends Connection
|
|||||||
* @param array $config 连接信息
|
* @param array $config 连接信息
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function parseDsn($config)
|
public function parseDsn($config)
|
||||||
{
|
{
|
||||||
$dsn = 'sqlsrv:Database=' . $config['database'] . ';Server=' . $config['hostname'];
|
$dsn = 'sqlsrv:Database=' . $config['database'] . ';Server=' . $config['hostname'];
|
||||||
if (!empty($config['hostport'])) {
|
if (!empty($config['hostport'])) {
|
||||||
@@ -96,11 +96,11 @@ class Sqlsrv extends Connection
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* SQL性能分析
|
* SQL性能分析
|
||||||
* @access protected
|
* @access public
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getExplain($sql)
|
public function getExplain($sql)
|
||||||
{
|
{
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace think\log\driver;
|
|||||||
/**
|
/**
|
||||||
* 本地化调试输出到文件
|
* 本地化调试输出到文件
|
||||||
*/
|
*/
|
||||||
class File
|
class File implements LogInterface
|
||||||
{
|
{
|
||||||
protected $config = [
|
protected $config = [
|
||||||
'time_format' => ' c ',
|
'time_format' => ' c ',
|
||||||
|
|||||||
25
library/think/log/driver/LogInterface.php
Normal file
25
library/think/log/driver/LogInterface.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace think\log\driver;
|
||||||
|
|
||||||
|
interface LogInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 日志写入接口
|
||||||
|
* @access public
|
||||||
|
* @param array $log 日志信息
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function save(array $log = []);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ namespace think\log\driver;
|
|||||||
/**
|
/**
|
||||||
* 调试输出到SAE
|
* 调试输出到SAE
|
||||||
*/
|
*/
|
||||||
class Sae
|
class Sae implements LogInterface
|
||||||
{
|
{
|
||||||
protected $config = [
|
protected $config = [
|
||||||
'log_time_format' => ' c ',
|
'log_time_format' => ' c ',
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
namespace think\log\driver;
|
namespace think\log\driver;
|
||||||
|
|
||||||
class Socket
|
class Socket implements LogInterface
|
||||||
{
|
{
|
||||||
public $port = 1116; //SocketLog 服务的http的端口号
|
public $port = 1116; //SocketLog 服务的http的端口号
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace think\log\driver;
|
|||||||
/**
|
/**
|
||||||
* 模拟测试输出
|
* 模拟测试输出
|
||||||
*/
|
*/
|
||||||
class Test
|
class Test implements LogInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* 日志写入接口
|
* 日志写入接口
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use think\Debug;
|
|||||||
/**
|
/**
|
||||||
* 页面Trace调试
|
* 页面Trace调试
|
||||||
*/
|
*/
|
||||||
class Trace
|
class Trace implements LogInterface
|
||||||
{
|
{
|
||||||
protected $config = [
|
protected $config = [
|
||||||
'trace_file' => '',
|
'trace_file' => '',
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace think\view\driver;
|
|||||||
use think\Exception;
|
use think\Exception;
|
||||||
use think\Log;
|
use think\Log;
|
||||||
|
|
||||||
class Php
|
class Php implements ViewInterface
|
||||||
{
|
{
|
||||||
// 模板引擎参数
|
// 模板引擎参数
|
||||||
protected $config = [
|
protected $config = [
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use think\Exception;
|
|||||||
use think\Log;
|
use think\Log;
|
||||||
use think\Template;
|
use think\Template;
|
||||||
|
|
||||||
class Think
|
class Think implements ViewInterface
|
||||||
{
|
{
|
||||||
// 模板引擎实例
|
// 模板引擎实例
|
||||||
private $template = null;
|
private $template = null;
|
||||||
|
|||||||
34
library/think/view/driver/ViewInterface.php
Normal file
34
library/think/view/driver/ViewInterface.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Copyright (c) 2006~2016 http://thinkphp.cn All rights reserved.
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
// | Author: liu21st <liu21st@gmail.com>
|
||||||
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace think\view\driver;
|
||||||
|
|
||||||
|
interface ViewInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 渲染模板文件
|
||||||
|
* @access public
|
||||||
|
* @param string $template 模板文件
|
||||||
|
* @param array $data 模板变量
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function fetch($template, $data = []);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 渲染模板内容
|
||||||
|
* @access public
|
||||||
|
* @param string $content 模板内容
|
||||||
|
* @param array $data 模板变量
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function display($content, $data = []);
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user