Uninote
Uninote
用户根目录
每日点滴

<!DOCTYPE html> <html><head><meta http-equiv='Content-Type' content='text/html; charset=utf8'><title>eson todo</title> <script> var g_resRoot = '../../__res/'; var g_json_outline = '{"children":[{"children":[],"level":1,"lvNumber":"1","text":"重复代码整理:"},{"children":[],"level":1,"lvNumber":"2","text":"yii header 设置方法"},{"children":[],"level":1,"lvNumber":"3","text":"log 研究yii的日志、use stack"},{"children":[{"children":[],"level":2,"lvNumber":"4.1","text":"不要重定向"}],"level":1,"lvNumber":"4","text":"代码优化"},{"children":[],"level":1,"lvNumber":"5","text":"需要重写的commits"},{"children":[],"level":1,"lvNumber":"6","text":"uri-parser"}],"level":0,"lvNumber":"","text":"eson todo"}'; </script> <link rel='stylesheet' type='text/css' href='../../__res/common.css'><style>.s0{color:#000000;} .s1{color:#000080;} .s2{color:#000000;} .s3{color:#660000;} .s4{color:#008000;} .s5{color:#660e7a;} .s6{color:#000000;} .s7{color:#c80000;} .s8{color:#0000ff;} .s9{color:#000000;} .s10{color:#000000;} </style> </head><body> <script src='../../__res/util.js'></script><div id='outline'> <li><a href='#ol_0' style='font-weight:bold; font-size:22px'>eson todo</a></li> <li> <a href='#ol_1' >重复代码整理:</a></li> <li> <a href='#ol_2' >yii header 设置方法</a></li> <li> <a href='#ol_3' >log 研究yii的日志、use stack</a></li> <li> <a href='#ol_4' >代码优化</a></li> <li> <a href='#ol_5' >不要重定向</a></li> <li> <a href='#ol_6' >需要重写的commits</a></li> <li> <a href='#ol_7' >uri-parser</a></li> </div>

<pre id='ol_0' class='title'>eson todo</pre> <pre><d class='s0'></d></pre> <h1 id='ol_1'>重复代码整理:</h1> <pre><d class='s1'>if </d><d class='s2'>(</d><d class='s3'>$is_login_bool </d><d class='s2'>&& file_exists(</d><d class='s4'>"./upload_pic/avatar_</d><d class='s2'>{</d><d class='s3'>$SESSION</d><d class='s2'>[</d><d class='s4'>'user_id'</d><d class='s2'>]}</d><d class='s4'>"</d><d class='s2'>) ) {</d></pre> <pre><d class='s2'> </d><d class='s3'>$user_pic </d><d class='s2'>= </d><d class='s4'>"./upload_pic/avatar</d><d class='s2'>{</d><d class='s3'>$SESSION</d><d class='s2'>[</d><d class='s4'>'user_id'</d><d class='s2'>]}</d><d class='s4'>"</d><d class='s2'>;</d></pre> <pre><d class='s2'>} </d><d class='s1'>else </d><d class='s2'>{</d></pre> <pre><d class='s2'> </d><d class='s3'>$user_pic </d><d class='s2'>= </d><d class='s4'>'./link/public/img/anonymous.png'</d><d class='s2'>;</d></pre> <pre><d class='s2'>}</d></pre> <pre><d class='s2'></d></pre> <pre><d class='s3'>$user_pic </d><d class='s2'>= </d><d class='s4'>"./upload_pic/avatar" </d><d class='s2'>. get_safe(</d><d class='s3'>$SESSION</d><d class='s2'>, </d><d class='s4'>'user_id'</d><d class='s2'>, </d><d class='s4'>""</d><d class='s2'>);</d></pre> <pre><d class='s1'>if </d><d class='s2'>(!file_exists(</d><d class='s3'>$user_pic</d><d class='s2'>))</d></pre> <pre><d class='s2'> </d><d class='s3'>$user_pic </d><d class='s2'>= </d><d class='s4'>'./link/public/img/anonymous.png'</d><d class='s2'>;</d></pre> <pre><d class='s0'>----or</d></pre> <pre><d class='s1'>if</d><d class='s2'>(</d><d class='s3'>$is_login_bool</d><d class='s2'>) {</d></pre> <pre><d class='s2'> </d><d class='s3'>$user_pic </d><d class='s2'>= </d><d class='s4'>"./upload_pic/avatar</d><d class='s2'>{</d><d class='s3'>$_SESSION</d><d class='s2'>[</d><d class='s4'>'user_id'</d><d class='s2'>]}</d><d class='s4'>"</d><d class='s2'>;</d></pre> <pre><d class='s2'>}</d></pre> <pre><d class='s1'>if</d><d class='s2'>(!file_exists(</d><d class='s3'>$user_pic</d><d class='s2'>)) {</d></pre> <pre><d class='s2'> </d><d class='s3'>$user_pic </d><d class='s2'>= </d><d class='s4'>'./link/book/img/anonymous.png'</d><d class='s2'>;;</d></pre> <pre><d class='s2'>}</d><d class='s0'></d></pre> <pre><d class='s1'>private function </d><d class='s2'>_checkout_signin()</d></pre> <pre><d class='s2'>{</d></pre> <pre><d class='s2'> CT(</d><d class='s5'>NAMESPACE </d><d class='s2'>. </d><d class='s4'>"</d><d class='s2'>\U</d><d class='s4'>serController::_checkout_signin(){}"</d><d class='s2'>);</d></pre> <pre><d class='s2'> </d><d class='s1'>if </d><d class='s2'>( (</d><d class='s1'>isset</d><d class='s2'>(</d><d class='s3'>$_SESSION</d><d class='s2'>[</d><d class='s4'>'user_id'</d><d class='s2'>]) && </d><d class='s1'>isset</d><d class='s2'>(</d><d class='s3'>$_SESSION</d><d class='s2'>[</d><d class='s4'>'user_info'</d><d class='s2'>])) ) {</d></pre> <pre><d class='s2'> </d><d class='s1'>return TRUE</d><d class='s2'>;</d></pre> <pre><d class='s2'> } </d><d class='s1'>else </d><d class='s2'>{</d></pre> <pre><d class='s2'> </d><d class='s1'>return FALSE</d><d class='s2'>;</d></pre> <pre><d class='s2'> }</d></pre> <pre><d class='s2'>}</d></pre> <pre><d class='s6'></d></pre> <h1 id='ol_2'>yii header 设置方法</h1> <pre><d class='s3'>$response </d><d class='s2'>= Yii::</d><d class='s5'>$app</d><d class='s2'>->getResponse();</d></pre> <pre><d class='s3'>$response</d><d class='s2'>-></d><d class='s5'>format </d><d class='s2'>= </d><d class='s3'>$response</d><d class='s2'>::</d><d class='s5'>FORMAT_RAW</d><d class='s2'>;</d></pre> <pre><d class='s3'>$response</d><d class='s2'>->getHeaders()->set(</d><d class='s4'>'Content-Type'</d><d class='s2'>, </d><d class='s4'>'image/png'</d><d class='s2'>);</d></pre> <pre><d class='s2'></d></pre> <pre><d class='s2'>Response::FORMAT_JSON;</d></pre> <pre><d class='s0'></d></pre> <t id='5c8134a1-4d4b-4d2d-9b57-733bad075762'> <pre class='tnd_head'>lv1= lv2= type=</pre> <h1 id='ol_3'>log 研究yii的日志、use stack</h1> <pre><d class='s0'>2018-05-05 16:00:58 [::1][-][-][error][yii\base\ErrorException:4] </d><d class='s7'>exception 'yii\base\ErrorException' with message 'syntax error, unexpected 'CT' (T_STRING)' in E:\uninote\mynote\basic\controllers\common\BaseController.php:90</d><d class='s0'></d></pre> <pre><d class='s7'>Stack trace:</d><d class='s0'></d></pre> <pre><d class='s0'>#0 E:\uninote\mynote\basic\vendor\yiisoft\yii2\BaseYii.php(14): ::spl_autoload_call()</d></pre> <pre><d class='s0'>#1 E:\uninote\mynote\basic\vendor\yiisoft\yii2\BaseYii.php(298): ::unknown()</d></pre> <pre><d class='s0'>#2 E:\uninote\mynote\basic\vendor\yiisoft\yii2\base\Module.php(661): yii\BaseYii::autoload()</d></pre> <pre><d class='s0'>#3 E:\uninote\mynote\basic\vendor\yiisoft\yii2\base\Module.php(661): ::spl_autoload_call()</d></pre> <pre><d class='s0'>#4 E:\uninote\mynote\basic\vendor\yiisoft\yii2\base\Module.php(661): ::class_exists()</d></pre> <pre><d class='s0'>#5 E:\uninote\mynote\basic\vendor\yiisoft\yii2\base\Module.php(619): yii\base\Module->createControllerByID()</d></pre> <pre><d class='s0'>#6 E:\uninote\mynote\basic\vendor\yiisoft\yii2\base\Module.php(544): yii\base\Module->createController()</d></pre> <pre><d class='s0'>#7 E:\uninote\mynote\basic\vendor\yiisoft\yii2\web\Application.php(105): yii\base\Module->runAction()</d></pre> <pre><d class='s0'>#8 E:\uninote\mynote\basic\vendor\yiisoft\yii2\base\Application.php(394): yii\web\Application->handleRequest()</d></pre> <pre><d class='s0'>#9 E:\uninote\mynote\basic\web\index.php(19): yii\base\Application->run()</d></pre> <pre><d class='s0'>#10 {main}</d></pre> <pre><d class='s0'></d></pre> <pre><d class='s0'>\app\models\Com::log 用yii原生的代替</d></pre> <pre><d class='s0'></d></pre> <pre><d class='s0'>68f79f9f5615295b83777cf9dc5edb84badc9016</d></pre> </t> <pre><d class='s0'></d></pre> <t id='b32816ec-10c9-4ee4-a332-6085d88ba489'> <pre class='tnd_head'>lv1=mynote lv2= type=todo</pre> <h1 id='ol_4'>代码优化</h1> <pre><d class='s0'>see branch optimize,另外,这个make_result应该放到一个base中:</d></pre> <pre><d class='s1'>protected function </d><d class='s2'>make_result(</d><d class='s3'>$errno</d><d class='s2'>, </d><d class='s3'>$data</d><d class='s2'>)</d></pre> <pre><d class='s2'>{</d></pre> <pre><d class='s2'> </d><d class='s1'>if </d><d class='s2'>(</d><d class='s3'>$data </d><d class='s2'>=== </d><d class='s1'>NULL</d><d class='s2'>) {</d></pre> <pre><d class='s2'> </d><d class='s3'>$data </d><d class='s2'>= [];</d></pre> <pre><d class='s2'> } </d><d class='s1'>else </d><d class='s2'>{</d></pre> <pre><d class='s2'> </d><d class='s3'>$errno </d><d class='s2'>= </d><d class='s8'>0</d><d class='s2'>;</d></pre> <pre><d class='s2'> }</d></pre> <pre><d class='s2'> </d><d class='s3'>$this</d><d class='s2'>-></d><d class='s5'>errno </d><d class='s2'>= </d><d class='s3'>$errno</d><d class='s2'>;</d></pre> <pre><d class='s2'> </d><d class='s3'>$a </d><d class='s2'>= </d><d class='s1'>array</d><d class='s2'>(</d><d class='s4'>"errno" </d><d class='s2'>=> </d><d class='s3'>$errno</d><d class='s2'>, </d><d class='s4'>"status" </d><d class='s2'>=> </d><d class='s3'>$errno </d><d class='s2'>=== </d><d class='s8'>0</d><d class='s2'>, </d><d class='s4'>"data" </d><d class='s2'>=> </d><d class='s3'>$data</d><d class='s2'>);</d></pre> <pre><d class='s2'> </d><d class='s1'>return </d><d class='s3'>$a</d><d class='s2'>;</d></pre> <pre><d class='s2'>}</d></pre> <pre><d class='s0'></d></pre> <h2 id='ol_5'>不要重定向</h2> <pre><d class='s0'>http://localhost:222/ -></d></pre> <pre><d class='s0'>http://localhost:222/error/art</d></pre> </t> <pre><d class='s0'></d></pre> <h1 id='ol_6'>需要重写的commits</h1> <pre><d class='s9'>SHA-1: 68f79f9f5615295b83777cf9dc5edb84badc9016</d></pre> <pre><d class='s9'></d></pre> <pre><d class='s9'>* </d><d class='s10'>【优化】- 减少api层的代码沉余封装公共api控制器</d></pre> <pre><d class='s10'></d></pre> <pre><d class='s10'><img src='..\pic\cf692959b13425e2fdf13e3fb80865ef.jpg' /></d><d class='s0'></d></pre> <pre><d class='s0'></d></pre> <h1 id='ol_7'>uri-parser</h1> <pre><d class='s0'><a href='https://github.com/thephpleague/uri-parser'>https://github.com/thephpleague/uri-parser</a></d></pre> <pre><d class='s0'>把demo跑起来,tests跑通</d></pre> </body></html>

eson_todo

fastadmin

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