コード例 #1
0
ファイル: PtApp.php プロジェクト: houlonglong/easytee-me
function cli_route()
{
    global $argv;
    $usage = "\nusage : \n\t php bin/cli.php --model=index --action=index --env=develop \n";
    if (count($argv) < 2) {
        throw new ErrorException($usage);
    }
    $shortopts = "";
    $longopts = array("model:", "action:", "env:");
    $options = getopt($shortopts, $longopts);
    if (empty($options['env'])) {
        $_SERVER['PT_ENV'] = "develop";
    } else {
        $_SERVER['PT_ENV'] = $options['env'];
    }
    pt_init();
    if (empty($options['model'])) {
        throw new ErrorException($usage);
    }
    if (empty($options['action'])) {
        throw new ErrorException($usage);
    }
    if (substr($options['model'], 0, 1) == '/') {
        $options['model'] = substr($options['model'], 1);
    }
    if (substr($options['model'], -4) == '.php') {
        $options['model'] = substr($options['model'], 0, -4);
    }
    foreach ($_SERVER['argv'] as $value) {
        if (substr($value, 0, 2) == "--") {
            $t = explode("=", substr($value, 2));
            if (!in_array($t[0], array("model", "action", "env"))) {
                $_REQUEST[$t[0]] = $t[1];
            }
        }
    }
    //var_dump($options);
    //print_r($_SERVER['argv']);
    //print_r($_SERVER['PT_ENV']);
    //exit;
    $model_file = "/" . $options['model'] . ".php";
    $action = $options['action'];
    route_model($model_file, $action, "cli");
}
コード例 #2
0
ファイル: boot.php プロジェクト: houlonglong/easytee-me
<?php

/**
 * Created by PhpStorm.
 * User: joseph
 * Date: 7/10/15
 * Time: 1:25 PM
 */
include_once __DIR__ . '/../app_et/init.php';
include_once PATH_APP . '/include/common.php';
function pt_autoload_test($classname)
{
}
spl_autoload_register('pt_autoload_test');
pt_init();