import() public static method

导入所需的类库 同java的Import 本函数有缓存功能
public static import ( string $class, string $baseUrl = '', string $ext = EXT ) : boolean
$class string 类库命名空间字符串
$baseUrl string 起始路径
$ext string 导入的文件扩展名
return boolean
Example #1
0
 /**
  * 架构函数
  * @access public
  */
 public function __construct()
 {
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
     //导入类库
     \think\Loader::import('vendor.Hprose.HproseHttpServer');
     //实例化HproseHttpServer
     $server = new \HproseHttpServer();
     if ($this->allowMethodList) {
         $methods = $this->allowMethodList;
     } else {
         $methods = get_class_methods($this);
         $methods = array_diff($methods, array('__construct', '__call', '_initialize'));
     }
     $server->addMethods($methods, $this);
     if (APP_DEBUG || $this->debug) {
         $server->setDebugEnabled(true);
     }
     // Hprose设置
     $server->setCrossDomainEnabled($this->crossDomain);
     $server->setP3PEnabled($this->P3P);
     $server->setGetEnabled($this->get);
     // 启动server
     $server->start();
 }
Example #2
0
 /**
  * 架构函数
  * @access public
  */
 public function __construct()
 {
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
     //导入类库
     \think\Loader::import('vendor.jsonrpc.jsonRPCServer');
     // 启动server
     \jsonRPCServer::handle($this);
 }
Example #3
0
 /**
  * 架构函数
  * @access public
  */
 public function __construct()
 {
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
     //导入类库
     \think\Loader::import('vendor.phprpc.phprpc_server');
     //实例化phprpc
     $server = new \PHPRPC_Server();
     if ($this->allowMethodList) {
         $methods = $this->allowMethodList;
     } else {
         $methods = get_class_methods($this);
         $methods = array_diff($methods, array('__construct', '__call', '_initialize'));
     }
     $server->add($methods, $this);
     if (APP_DEBUG || $this->debug) {
         $server->setDebugMode(true);
     }
     $server->setEnableGZIP(true);
     $server->start();
     echo $server->comment();
 }
Example #4
0
/**
 * 快速导入Traits
 * @param string $class trait库
 * @param string $ext 类库后缀
 * @return boolean
 */
function T($class, $ext = EXT)
{
    return \think\Loader::import($class, TRAIT_PATH, $ext);
}
Example #5
0
 /**
  * 快速导入第三方框架类库 所有第三方框架的类库文件统一放到 系统的Vendor目录下面
  * @param string    $class 类库
  * @param string    $ext 类库后缀
  * @return boolean
  */
 function vendor($class, $ext = EXT)
 {
     return Loader::import($class, VENDOR_PATH, $ext);
 }
Example #6
0
<?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 <*****@*****.**>
// +----------------------------------------------------------------------
namespace think\model;

use think\Lang;
use think\Loader;
\think\Loader::import('modle/Adv', TRAIT_PATH, EXT);
/**
 * MongoModel模型类
 * 实现了ODM和ActiveRecords模式
 */
class Mongo extends \think\Model
{
    use \traits\model\Adv;
    // 主键类型
    const TYPE_OBJECT = 1;
    const TYPE_INT = 2;
    const TYPE_STRING = 3;
    // 主键名称
    protected $pk = '_id';
    // _id 类型 1 Object 采用MongoId对象 2 Int 整形 支持自动增长 3 String 字符串Hash
    protected $_idType = self::TYPE_OBJECT;
Example #7
0
<?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 <*****@*****.**>
// +----------------------------------------------------------------------
namespace think;

\think\Loader::import('controller/Jump', TRAIT_PATH, EXT);
use think\Exception;
use think\exception\ValidateException;
class Controller
{
    use \traits\controller\Jump;
    // 视图类实例
    protected $view;
    // Request实例
    protected $request;
    // 验证失败是否抛出异常
    protected $failException = false;
    // 是否批量验证
    protected $batchValidate = false;
    /**
     * 前置操作方法列表
     * @var array $beforeActionList
     * @access protected
Example #8
0
File: View.php Project: cnzin/think
<?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 <*****@*****.**>
// +----------------------------------------------------------------------
namespace think\model;

\think\Loader::import('model/View', TRAIT_PATH, EXT);
class View extends \think\Model
{
    use \traits\model\View;
}
Example #9
0
 public function testImport()
 {
     $this->assertEquals(true, Loader::import('think.log.driver.Sae'));
     $this->assertEquals(false, Loader::import('think.log.driver.MyTest'));
 }
Example #10
0
File: Adv.php Project: cnzin/think
<?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 <*****@*****.**>
// +----------------------------------------------------------------------
namespace think\model;

\think\Loader::import('model/Adv', TRAIT_PATH, EXT);
\think\Loader::import('model/Transaction', TRAIT_PATH, EXT);
class Adv extends \think\Model
{
    use \traits\model\Adv;
    use \traits\model\Transaction;
}
Example #11
0
<?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 <*****@*****.**>
// +----------------------------------------------------------------------
namespace think\model;

\think\Loader::import('model/Relation', TRAIT_PATH, EXT);
class Relation extends \think\Model
{
    use \traits\model\Relation;
}