Uninote
Uninote
用户根目录
每日点滴
 eson todo
eson todo

重复代码整理:

if ($is_login_bool && file_exists("./upload_pic/avatar_{$_SESSION['user_id']}") ) {
    $user_pic = "./upload_pic/avatar_{$_SESSION['user_id']}";
} else {
    $user_pic = './link/public/img/anonymous.png';
}
$user_pic = "./upload_pic/avatar_" . get_safe($_SESSION, 'user_id', "");
if (!file_exists($user_pic))
    $user_pic = './link/public/img/anonymous.png';
----or
if($is_login_bool) {
    $user_pic = "./upload_pic/avatar_{$_SESSION['user_id']}";
}
if(!file_exists($user_pic)) {
    $user_pic = './link/book/img/anonymous.png';;
}
private function _checkout_signin()
{
    CT(__NAMESPACE__ . "\UserController::_checkout_signin(){}");
    if ( (isset($_SESSION['user_id']) && isset($_SESSION['user_info'])) ) {
        return TRUE;
    } else {
        return FALSE;
    }
}

yii header 设置方法

$response = Yii::$app->getResponse();
$response->format = $response::FORMAT_RAW;
$response->getHeaders()->set('Content-Type', 'image/png');
Response::FORMAT_JSON;
lv1= lv2= type=

log 研究yii的日志、use stack

2018-05-05 16:00:58 [::1][-][-][error][yii\base\ErrorException:4] exception 'yii\base\ErrorException' with message 'syntax error, unexpected 'CT' (T_STRING)' in E:\uninote\mynote\basic\controllers\common\BaseController.php:90
Stack trace:
#0 E:\uninote\mynote\basic\vendor\yiisoft\yii2\BaseYii.php(14): ::spl_autoload_call()
#1 E:\uninote\mynote\basic\vendor\yiisoft\yii2\BaseYii.php(298): ::unknown()
#2 E:\uninote\mynote\basic\vendor\yiisoft\yii2\base\Module.php(661): yii\BaseYii::autoload()
#3 E:\uninote\mynote\basic\vendor\yiisoft\yii2\base\Module.php(661): ::spl_autoload_call()
#4 E:\uninote\mynote\basic\vendor\yiisoft\yii2\base\Module.php(661): ::class_exists()
#5 E:\uninote\mynote\basic\vendor\yiisoft\yii2\base\Module.php(619): yii\base\Module->createControllerByID()
#6 E:\uninote\mynote\basic\vendor\yiisoft\yii2\base\Module.php(544): yii\base\Module->createController()
#7 E:\uninote\mynote\basic\vendor\yiisoft\yii2\web\Application.php(105): yii\base\Module->runAction()
#8 E:\uninote\mynote\basic\vendor\yiisoft\yii2\base\Application.php(394): yii\web\Application->handleRequest()
#9 E:\uninote\mynote\basic\web\index.php(19): yii\base\Application->run()
#10 {main}
\app\models\Com::log 用yii原生的代替
68f79f9f5615295b83777cf9dc5edb84badc9016
lv1=mynote lv2= type=todo

代码优化

see branch optimize,另外,这个make_result应该放到一个base中:
protected function make_result($errno, $data)
{
    if ($data === NULL) {
        $data = [];
    } else {
        $errno = 0;
    }
    $this->errno = $errno;
    $a = array("errno" => $errno, "status" => $errno === 0, "data" => $data);
    return $a;
}

不要重定向

http://localhost:222/ ->
http://localhost:222/error/art

需要重写的commits

SHA-1: 68f79f9f5615295b83777cf9dc5edb84badc9016
* 【优化】- 减少api层的代码沉余封装公共api控制器

uri-parser

https://github.com/thephpleague/uri-parser
把demo跑起来,tests跑通

eson_todo

fastadmin

点赞(0) 阅读(17) 举报
目录
标题