最近工作有些忙,但不忘做些日常总结,温故而知新嘛。
- 尽量使用php内置方法,因为二维数组使用了个+;导致php版本不兼容
- git限制重要配置不要提交到版本库,因为测试环境,本地环境,线上环境等都不相同,每个人电脑也不同
- 代码中不要写死代码;因为涉及到负载均衡,等多web服务器的时候,特别是多同事协作的时候,太难部署了,建议都入库或者直接写入配置文件。
- 代码的兼容性考虑,可以直接通过先sql语句运行,再结合php代码处理。因为线上正式环境情况太多了,“存在”与否已经不好处理了!最后都当做新数据来更新处理。
- 虽然代码一样,但是可根据不同客户分配不同插件?怎么做到,sql更新库表即可
- 快速调试日志,可在编辑器中打开节省时间
- git版本控制如果新建了文件,然后修改文件名,文件是不会被git跟踪的,要注意
- update语句字段禁止为空!如update xx set a= where xx=1
空判断要刨根
//错误
$option = Option::getList(['insure_platform'], $this->store->id, 'admin');
if ($option) {
$insure_platform = array_column((array)\Yii::$app->serializer->decode($option['insure_platform']), null, 'platform');
} else {
$insure_platform = [];
}
//正确
$option = Option::getList(['insure_platform'], $this->store->id, 'admin');
if ($option['insure_platform']) {
$insure_platform = array_column((array)\Yii::$app->serializer->decode($option['insure_platform']), null, 'platform');
} else {
$insure_platform = [];
}