Author: Seven Du (lovevipdsw@vip.qq.com)
Example #1
0
 /**
  * 初始化
  *
  * @return void
  * @author Seven Du <*****@*****.**>
  **/
 protected static function init()
 {
     self::$_root = dirname(__FILE__);
     /* # 设置时区 */
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set('Asia/Shanghai');
     }
     /* 加载必要文件 */
     self::import(self::getRootPath(), 'AutoLoader', 'TsAutoLoader', '.php');
 }
 public function routesAction()
 {
     echo $this->request->get('param', 'int');
     $this->mapp->get('/MicroApp/routes/{param}', array($this, 'getParam'));
     $res = Ts::find(array('a' => 'cd'));
     echo $res->serialize();
     print_r($res->toArray());
     die;
     $res = Ts::findByA('cd');
     //        print_r($res->next());
     //        print_r($res->getFirst());
     //        print_r($res->getLast());
     die;
     echo 'forward to routesAction';
 }
Example #3
0
 /**
  * 初始化
  *
  * @author Seven Du <*****@*****.**>
  **/
 protected static function init()
 {
     self::$_root = dirname(__FILE__);
     /* # 设置时区 */
     if (function_exists('date_default_timezone_set')) {
         date_default_timezone_set('Asia/Shanghai');
     }
     /* 初始化数据库 */
     self::$capsule = new Capsule();
     self::$capsule->addConnection((array) (include TS_CONFIGURE . '/database.php'));
     self::$capsule->setEventDispatcher(new Dispatcher(new Container()));
     // Make this Capsule instance available globally via static methods... (optional)
     self::$capsule->setAsGlobal();
     // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
     self::$capsule->bootEloquent();
     // 关闭日志功能
     self::$capsule->connection()->disableQueryLog();
 }
Example #4
0
/**
 * 载入文件 去重\缓存.
 * @param  string $filename 载入的文件名
 * @return bool
 */
function tsload($filename)
{
    return Ts::import($filename, '');
}
Example #5
0
//网站根路径设置 // 兼容旧的地方。
define('SITE_PATH', dirname(__FILE__));
/* 新系统需要的一些配置 */
define('TS_ROOT', dirname(__FILE__));
// Ts根
define('TS_APPLICATION', TS_ROOT . '/apps');
// 应用存在的目录
define('TS_CONFIGURE', TS_ROOT . '/config');
// 配置文件存在的目录
define('TS_STORAGE', '/storage');
// 储存目录,需要可以公开访问,相对于域名根
/* 应用开发中的配置 */
define('TS_APP_DEV', false);
// 新的系统核心接入
require TS_ROOT . '/src/Build.php';
Ts::import(TS_ROOT, 'src', 'old', 'core', '.php');
if (isset($_GET['debug'])) {
    C('APP_DEBUG', true);
    C('SHOW_RUN_TIME', true);
    C('SHOW_ADV_TIME', true);
    C('SHOW_DB_TIMES', true);
    C('SHOW_CACHE_TIMES', true);
    C('SHOW_USE_MEM', true);
    C('LOG_RECORD', true);
    C('LOG_RECORD_LEVEL', array('EMERG', 'ALERT', 'CRIT', 'ERR', 'SQL'));
}
App::run();
if (C('APP_DEBUG')) {
    //数据库查询信息
    echo '<div align="left">';
    //缓存使用情况
Example #6
0
    \Medz\Component\Filesystem\Filesystem::mkdir(dirname($timer), 0777);
    file_put_contents($timer, time());
}
define('APP_PUBLIC_URL', sprintf('%s%s/app/%s', SITE_URL, TS_STORAGE, strtolower(APP_NAME)));
//设置语言包
setLang();
/*
 * 新应用入口文件
 */
if (file_exists(sprintf('%s/bootstrap.php', APP_PATH))) {
    Ts::import(APP_PATH, 'bootstrap', '.php');
    /*
     * 兼容旧的应用
     */
} elseif (file_exists(sprintf('%s/common.php', APP_COMMON_PATH))) {
    Ts::import(APP_COMMON_PATH, 'common', '.php');
}
//合并应用配置
if (file_exists(APP_CONFIG_PATH . '/config.php')) {
    tsconfig(include APP_CONFIG_PATH . '/config.php');
}
//根据应用配置重定义以下常量
if (C('THEME_NAME')) {
    tsdefine('THEME_NAME', C('THEME_NAME'));
}
//根据应用配置重定义以下常量
if (C('APP_TPL_PATH')) {
    tsdefine('APP_TPL_PATH', C('APP_TPL_PATH'));
}
//如果是部署模式、则如下定义
if (C('DEPLOY_STATIC')) {
Example #7
0
<?php

/* 功能不完善,后续根据开发需要,慢慢完善,替换以前系统底层 */
/* 一步一步替换掉 */
$file = dirname(__FILE__) . '/vendor/autoload.php';
if (!file_exists($file)) {
    echo '<pre>';
    echo 'You must set up the project dependencies, run the following commands:', PHP_EOL, 'curl -sS https://getcomposer.org/installer | php', PHP_EOL, 'php composer.phar install', PHP_EOL;
    echo '</pre>';
    exit;
}
$loader = (include $file);
/* Run */
Ts::run($loader);
Example #8
0
<?php

/* 功能不完善,后续根据开发需要,慢慢完善,替换以前系统底层 */
/* 一步一步替换掉 */
/**
 * 定义根目录
 **/
define('TS_ROOT', dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR);
include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Ts.php';
Ts::run();