コード例 #1
0
ファイル: Route.php プロジェクト: teotong/TeoPHP
 public function run()
 {
     $a = explode('/', preg_replace('/^\\//', '', $_SERVER['PATH_INFO'], 1));
     //        var_dump($a);exit;
     $action_num = count($a);
     if ($action_num == 1) {
         //对内api接口
         //访问例如:http://framework.mytest.com/add_folder?a=bb
         $this->folder = 'api';
         $action = $a[0];
         $action = strtolower(str_replace('_', '', trim($action)));
     } elseif ($action_num == 2) {
         //web应用程序
         //访问例如:http://framework.mytest.com/index/index?a=bb
         $this->folder = 'app';
         $action = implode('\\', $a);
         $action = strtolower(trim($action));
     } else {
         header('HTTP/1.1 404 Not Found');
         exit;
     }
     $actionsMap = \TeoPHP\Application::getConfig($this->folder, $this->config_path);
     if (!array_key_exists($action, $actionsMap)) {
         header('HTTP/1.1 404 Not Found');
         exit;
     }
     //        var_dump($actionsMap[$action]);exit;
     //从actionMap获得的路由地址 即configs/route里的action地址 例如: array('index\\Index', true)
     $this->route_address = $actionsMap[$action];
     return $this;
 }
コード例 #2
0
ファイル: MySQL.php プロジェクト: teotong/TeoPHP
 /**
  * 唯一单例入口
  * 数据库的名字
  * @param $db
  * 数据库类型 主库还是副库 master or slave
  * @param $db_type
  * 是否长连接 true or false
  * @param bool $p_connect
  * @param null $timeout
  * @param null $charset
  * @return mixed
  */
 public static function connect($db, $db_type, $p_connect = false, $timeout = null, $charset = null)
 {
     if (empty(self::$connects[$db][$db_type])) {
         //获得配置文件
         self::$config = \TeoPHP\Application::getConfig('resource');
         self::$db = $db;
         self::$db_type = $db_type;
         self::$p_connect = $p_connect;
         self::$timeout = $timeout;
         self::$charset = $charset;
         self::$charset = $charset;
         self::$charset = $charset;
         self::$connects[$db][$db_type] = new self();
     }
     return self::$connects[$db][$db_type];
 }
コード例 #3
0
ファイル: Login.php プロジェクト: teotong/TeoPHP
 public function doAction()
 {
     $a = Application::getConfig('resource');
     var_dump($a);
 }
コード例 #4
0
ファイル: interface.php プロジェクト: teotong/TeoPHP
<?php

//接口
define('BASEDIR', __DIR__);
require BASEDIR . '/TeoPHP/Loader.php';
spl_autoload_register('\\TeoPHP\\Loader::autoload');
if (!is_readable('vendor')) {
    die;
}
require 'vendor/autoload.php';
$a = explode('/', preg_replace('/^\\//', '', $_SERVER['PATH_INFO'], 1));
$action = implode('\\', $a);
$action = strtolower(trim($action));
$actionsMap = \TeoPHP\Application::getConfig('route_interface');
if (!array_key_exists($action, $actionsMap)) {
    header('HTTP/1.1 404 Not Found');
    exit;
}
\TeoPHP\Application::run($actionsMap[$action][0], $folder);