Larravel adds model method annotation to make PHP Storm have syntax prompt Author: Chuwen Time: 2021-06-30 Classification: Laravel , PHP comment ##Installation 1. Install the 'Larravel' plug-in on the PHP Storm ! []( https://cdn.nowtime.cc/2021/06/30/1433782083.png ) 2. Add the 'barryvdh/laravel ide helper' package to the project ```shell composer require barryvdh/laravel-ide-helper ``` ##Using 1. Add comments for * * all models * * ```shell php artisan ide-helper:models ``` 2. Add comments for * * Specify model * * >The following shows how to add comments for the 'App Models Admin' model. * App Models Admin * is the namespace name of the model ```shell php artisan ide-helper:models \App\Models\Admin ``` 3. Generate comments for Facades ```shell php artisan ide-helper:generate ``` 4. Generate PHPstorm Meta file ```shell php artisan ide-helper:meta ``` ##Screenshot after running as "model annotation" ! []( https://cdn.nowtime.cc/2021/06/30/3502548972.png )
I asked a question in CSDN when I wanted to implement a function in PHP Author: Chuwen Time: 2021-06-28 Classification: talk of everything under the sun comment ##Subject matter When I was free, I suddenly searched my * * QQ trumpet * * on Google. Unexpectedly, there would be unexpected gains. I even raised a question about PHP on CSDN five or six years ago (October 28, 2015) ! []( https://cdn.nowtime.cc/2021/06/28/2150184956.png ) ! []( https://cdn.nowtime.cc/2021/06/28/3178275766.png ) Original content: ``` <? php $auth= http://g.xsscp.com/include/code1.php?url= $_SERVER['HTTP_HOST']"; <? php $url = " http://g.xsscp.com/include/code1.php?url= $_SERVER['HTTP_HOST']"; $html = file_get_contents($url); if(! in_array($_SERVER['HTTP_HOST'], array(echo $html;))) { Exit ('64407039 reminds you that your domain name is not authorized! Or visit directly through the website! For authorization, please contact QQ: 644407039 '); } ?> It's just not enough. Please help me, The idea is as follows hypothesis $_SERVER['HTTP_HOST']" Equal to r.xsscp.com So this website http://g.xsscp.com/include/code1.php?url= $_SERVER['HTTP_HOST']" Becomes http://g.xsscp.com/include/code1.php?url=r.xsscp.com If authorized, return to the current URL And passed. If there is no authorization, return No Admittance Benefiting from dripping water, when Yongquan reports pictures If the above code doesn't work, you can refer to the following figure for design. This code is sent by someone else and is also authorized. Only part of it has been shown. ``` ###Let's look at the code: >Bad writing and grammar mistakes ```php <? php $url = " http://g.xsscp.com/include/code1.php?url= $_SERVER['HTTP_HOST']"; $html = file_get_contents($url); if(! in_array($_SERVER['HTTP_HOST'], array(echo $html;))) { Exit ('64407039 reminds you that your domain name is not authorized! Or visit directly through the website! For authorization, please contact QQ: 644407039 '); } ?> ``` ##It's not over yet. I searched my QQ again >Then I found the code I wrote. I don't know the exact age. At this time, I should have mastered the use of MySQL in PHP. I should know a little about regular SQL statements. But at this time, only the class library written by others will be called, and the native 'mysql' and 'mysqli' will not > >As can be seen from the following, I still don't understand the 'return' statement, which results in 'if else' infinite nesting. After I learned 'ThinkPHP', I learned that the method will terminate execution when it encounters a retrn > >In addition, the grammar is not rigorous, thinking that there is only success and no failure ```php <? php class API{ function idiom($idiom){ global $DB; If (stristr ($idiom, 'Idiom Solitaire')){ $idiom=explore ('Idiom Solitaire ', $idiom); if($idiom['1']){ $row=$DB->get_row("SELECT * FROM `api_idiom` WHERE `name`='{$idiom['1']}' LIMIT 1"); if($row['name']==$idiom['1']){ $count=utf8_strlen($idiom['1']); $key=mb_substr($idiom,($count-1),$count,'UTF-8'); $row=$DB->get_row("SELECT * FROM `api_idiom` WHERE `name` LIKE '{$idiom['1']}%' ORDER BY RAND() LIMIT 1"); if($row['name']){ return $row['name']; }else{ Return 'You're too good. I can't catch you anymore. Let's use another idiom to play (\\\\\\\\\\\\\\\\; } }else{ Return 'Are you sure this idiom ('. $idiom ['1 '].') exists? Don't fool me; } }else{ $row=$DB->get_row("SELECT * FROM `api_idiom` ORDER BY RAND() LIMIT 1"); return $row['name']; } }Elseif (stristr ($idiom, 'idiom')){ $idiom=explore ('idiom ', $idiom); if($idiom['1']){ $row=$DB->get_row("SELECT * FROM `api_idiom` WHERE `name`='{$idiom['1']}' LIMIT 1"); if($row['name']==$idiom['1']){ Return 'Pronunciation:'$ row['spell'].' \N Idiom: '$ row['name'].' \N n Definition: '$ row['content']; }else{ Return 'Are you sure this idiom ('. $idiom ['1 '].') exists? Don't fool me; } }else{ Return 'You haven't entered the idiom to query its definition~(● - ●)'; } } #Function Die } function query_express($nu){ global $DB; if(!$ nu){ Return 'Please enter the waybill number to query the express information!'; }else{ $express=json_decode(curl_get(' http://www.kuaidi100.com/autonumber/auto?num= '.$ nu),true); $exname=$express[0]['comCode']; if(!$ exname){ Return 'Please enter the waybill number correctly!'; }else{ $query=json_decode(curl_get(' http://www.kuaidi100.com/query?type= '.$ exname.'&postid='.$nu),true); if($query['status']=='400'){ Return 'Query failed! Maybe the logistics information of the goods has not been updated, please check again later! '; }else{ if($query['status']=='201'){ Return 'The query failed. The reason is: n1. Maybe the logistics information of the goods has not been updated. Please check again later! \N n2. The waybill number does not exist [Please check whether the waybill number is entered correctly!] or it has expired! \N nPS: If this prompt appears when the waybill number exists, please contact the express to query API author QQ: 1361289290, thank you for your cooperation! '; }else{ $com=$query['com']; if($query['state']=='0'){ $state='Goods are in transit! '; }elseif($query['state']=='1'){ $state='The goods have been collected by the express company'; }elseif($query['state']=='2'){ $state='There was a problem during the delivery of the goods'; }elseif($query['state']=='3'){ $state='The recipient has signed in'; }elseif($query['state']=='4'){ $state='The goods are returned due to the user's refusal to sign, over area and other reasons, and the sender has signed for them'; }elseif($query['state']=='5'){ $state='The express delivery is in progress'; }elseif($query['state']=='3'){ $state='The goods are being returned to the sender'; }else{ $state='Status query failed, please query later!'; } $row=$DB->get_row("SELECT * FROM `api_expresscom` WHERE `com`='$com' LIMIT 1"); $arrlength=count($query['data']); for($i=0;$ i<$arrlength;$i++){ $data.=$ query['data'][$i]['time'].' \n'.$ query['data'][$i]['context'].' \n\n'; } Return 'Query the waybill number:'$ nu.'['.$row['name'].'] \N Cargo status: '$ State. ' n n'. $data. 'Query time:'. date ('Y-m-d H: i: s'); } } } } #Function Die } function joke(){ global $DB; $row=$DB->get_row("SELECT * FROM `api_joke` ORDER BY RAND() LIMIT 1"); return '《'.$ row['title'].'》 \n'.$ row['text']; } function historic($msg){ global $DB; If (stristr ($msg, 'today')){ $m=date('m'); $d=date('d'); }else{ $text=str_replace (Array ('days in history '),' ', $msg); $t=explore ('month ', $text); $m=$t['0']; $d=$t['1']; } if($m && $d){ $m=str_replace(Array('01','02','03','04','05','06','07','08','09'), Array('01'=>'1','02'=>'2','03'=>'3','04'=>'4','05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9'),$m); if($m<'0'){$m='1';}elseif($m>'13'){$m='12';} $d=str_replace(Array('01','02','03','04','05','06','07','08','09'), Array('01'=>'1','02'=>'2','03'=>'3','04'=>'4','05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9'),$d); if($d<'0'){$d='1';}elseif($d>'32'){$d='31';} }else{ $m=str_replace(Array('01','02','03','04','05','06','07','08','09'), Array('01'=>'1','02'=>'2','03'=>'3','04'=>'4','05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9'), date('m')); $d=str_replace(Array('01','02','03','04','05','06','07','08','09'), Array('01'=>'1','02'=>'2','03'=>'3','04'=>'4','05'=>'5','06'=>'6','07'=>'7','08'=>'8','09'=>'9'), date('d')); } } } ``` --- Only this memory
Docker image slimming - multi-stage construction Author: Chuwen Time: 2021-06-21 Classification: Docker comment Reference: https://zhuanlan.zhihu.com/p/161685245 Then, I wrote a 'Dockerfile' by myself, and the construction result is indeed nearly * * 500MB less than before** ```dockerfile FROM centos:centos7 AS build ENV NGINX_VERSION=1.21.0 ENV NGINX_URL= http://nginx.org/download/nginx- $NGINX_VERSION.tar.gz #Installation Dependencies RUN yum -y update && \ yum -y install gcc gcc-c++ autoconf automake make && \ yum -y install zlib zlib-devel openssl* pcre* wget #MAINTAINER information MAINTAINER shine09 i@nowtime.cc #Download Nginx source code ADD $NGINX_URL /tmp/ #Download nginx http concat source code ADD https://codeload.github.com/alibaba/nginx-http-concat/tar.gz/1.2.2 /tmp/ #Switch directory WORKDIR /tmp #Decompress http concat extension RUN tar -xzvf 1.2.2 && \ cp -r nginx-http-concat-1.2.2/ /usr/local/src/ && \ mkdir -p {/usr/local/nginx/logs,/var/lock} && \ useradd -M -s /bin/bash nginx && \ tar -zxvf nginx-$NGINX_VERSION.tar.gz && \ mkdir -p /usr/local/nginx && \ cd /tmp/nginx-$NGINX_VERSION \ && ./ configure --prefix=/etc/nginx --user=nginx --group=nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --http-log-path=/var/log/nginx/access.log \ --pid-path=/var/run/nginx.pid \ --lock-path=/var/run/nginx.lock \ --with-http_stub_status_module \ --with-http_ssl_module \ --with-http_sub_module \ --add-module=/usr/local/src/nginx-http-concat-1.2.2 \ && make && make install && \ rm -rf /tmp && \ /etc/nginx/sbin/nginx -c /etc/nginx/nginx.conf && \ ln -s /usr/local/nginx/sbin/* /usr/local/sbin/ #Phase II FROM centos:centos7 COPY --from=build /etc/nginx /etc/nginx RUN mkdir -p {/var/lock,/var/log/nginx/} && \ ln -s /etc/nginx/sbin/nginx /usr/local/sbin/nginx && \ useradd -M -s/bin/bash nginx #EXPOSE mapping port EXPOSE 80 443 #CMD runs the following command #CMD ["nginx"] CMD ["/etc/nginx/sbin/nginx","-g","daemon off;"] #Build Mirror #docker build -t shine09/nginx:v1 . ``` ```log ➜ nginx git:(master) ✗ docker history sha256:31b34e5b2e4b06756098ab0f07930f4c7d5671ef9155936bb8d0092787772f71 IMAGE CREATED CREATED BY SIZE COMMENT 31b34e5b2e4b 6 minutes ago CMD ["/etc/nginx/sbin/nginx" "-g" "daemon of… 0B buildkit.dockerfile.v0 <missing> 6 minutes ago EXPOSE map[443/tcp:{} 80/tcp:{}] 0B buildkit.dockerfile.v0 <missing> 6 minutes ago RUN /bin/sh -c mkdir -p {/var/lock,/var/log/… 360kB buildkit.dockerfile.v0 <missing> 18 minutes ago COPY /etc/nginx /etc/nginx # buildkit 6.18MB buildkit.dockerfile.v0 <missing> 7 months ago /bin/sh -c #(nop) CMD ["/bin/bash"] 0B <missing> 7 months ago /bin/sh -c #(nop) LABEL org.label-schema.sc… 0B <missing> 7 months ago /bin/sh -c #(nop) ADD file:b3ebbe8bd304723d4… 204MB ```
Vue.js error [Vue warn]: Computed property "getSearchOther" was assigned to but it has no setter Author: Chuwen Time: 2021-06-15 Classification: Vue.js comment ```log [Vue warn]: Computed property "getSearchOther" was assigned to but it has no setter. ``` I wrote: ```js //Some codes are omitted here watch:{ getSearchOther() { return this.SearchOther }, } //Some codes are omitted here ``` ##Solution Manually give 'get' and 'set' methods Refer to official documents:[ https://cn.vuejs.org/v2/guide/computed.html# Calculation property setter]( https://cn.vuejs.org/v2/guide/computed.html#%E8%AE%A1%E7%AE%97%E5%B1%9E%E6%80%A7%E7%9A%84 -setter " https://cn.vuejs.org/v2/guide/computed.html# Calculated property setter ") ```js //Some codes are omitted here watch:{ getSearchOther: { get() { return this.SearchOther }, set(newVal) { this.SearchOther = newVal; } }, } //Some codes are omitted here ```
A whole gadget - Jiayu's electricity consumption details query Author: Chuwen Time: 2021-06-14 Classification: PHP comment >Although it is a small thing, in order to make it more perfect, it also has 2 free time in the sky Project address: https://github.com/PrintNow/jiayu-hydropower-query Online preview: https://nowtime.cc/jiayu/ ! [421623676168_. pic_hd copy. jpg]( https://cdn.nowtime.cc/2021/06/14/4055147831.jpg )