叶测试 发布的文章

composer install和update

所有依赖都存在composer.json中,由于composer.json中相应库版本号未必为精确版本,所以同一份composer.json在不同时刻我们可能拉取到不同的依赖文件(默认拉取最新),从而可能导致问题。

当你执行composer update的时候,composer会去读取composer.json中指定的依赖,去分析他们,并且去拉取符合条件最新版本的依赖。然后他会把所拉取到的依赖放入vendor目录下,并且把所有拉取的依赖的精确版本号写入composer.lock文件中。

composer install所执行的事情非常类似,只在第一步的时候有差别。当你本地如果已经存在一份composer.lock时,它将会去读取你的composer.lock而非composer.json,并且以此为标准去下载依赖。当你本地没有composer.lock的时候,它所做的事情和composer update其实并没有区别。

可指定依赖更新,如 composer update monolog/monolog

When calling Ramsey\Uuid\Converter\Time\DegradedTimeConverter::calculateTime on a 32-bit system, Moontoast\Math\BigNumber must be present.

解决:https://github.com/ramsey/uuid/issues/153

This is correct. Some of the math involved when dealing with UUIDs is impossible on 32-bit systems. This is because a UUID is an unsigned 128-bit integer, and the time portion of a version 1 UUID is an unsigned 64-bit number. PHP on a 32-bit system only supports signed integers up to 2147483647.

Installing the moontoast/math library should fix your issue:

composer require moontoast/math

MYSQL5.7版本sql_mode=only_full_group_by问题

错误信息
`SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #3
of SELECT list is not in GROUP BY clause and contains nonaggregated column
'iicityYii.opportunity_conditions.money' which is not functionally dependent
on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by`

  1. 查看 sql_mode
    select @@global.sql_mode
  2. 去掉 ONLY_FULL_GROUP_BY
    set @@global.sql_mode ='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION';

或者:
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));

或者,修改mysql配置文件,新增
[mysqld]
sql-mode=""

ThinkPHP5 自定义模版标签tablib

ThinkPHP5 自定义模版标签tablib

新建文件application/common/taglib/Diy.php
Diy.php

<?php
// +----------------------------------------------------------------------
// | 自定义模版标签
// +----------------------------------------------------------------------
// | Author: SenSen <1050575278> 2018-12
// +----------------------------------------------------------------------
namespace app\common\taglib;

use think\Db;
use think\template\TagLib;

class Sen extends TagLib
{
    protected $tags = [
        'arclist' => ['attr'=> 'field,id,limit,cid,order,name,flag,type', 'close'=>1],
        'show' => ['attr'=> 'title,field', 'close'=>0],
    ];

    /**
     * 文章标签
     * @param $tag
     * @param $content
     * @return string
     */
    public function tagArclist($tag, $content)
    {
        $id = isset($tag['id']) ? $tag['id'] : 'vo';
        $order = empty($tag['order']) ? "'id DESC'" : '"'.$tag['order'].'"';
        $name = 'article';
        $field = "''";
        if (!empty($tag['field'])) {
            if (strpos($tag['field'], '$') === 0) {
                $field = $tag['field'];
                $this->autoBuildVar($field);
            } else {
                $field = "'{$tag['field']}'";
            }
        }
        $cid = "''";
        if (!empty($tag['cid'])) {
            if (strpos($tag['cid'], '$') === 0) {
                $cid = $tag['cid'];
                $this->autoBuildVar($cid);
            } else {
                $cid = "'{$tag['cid']}'";
            }
        }
        $flag = "''";
        if (!empty($tag['flag'])) {
            if (strpos($tag['flag'], '$') === 0) {
                $flag = $tag['flag'];
                $this->autoBuildVar($flag);
            } else {
                $flag = "'{$tag['flag']}'";
            }
        }
        $type = "''";
        if (!empty($tag['type'])) {
            if (strpos($tag['type'], '$') === 0) {
                $type = $tag['type'];
                $this->autoBuildVar($type);
            } else {
                $type = "'{$tag['type']}'";
            }
        }
        $limit = "''";
        if (!empty($tag['limit'])) {
            if (strpos($tag['limit'], '$') === 0) {
                $limit = $tag['limit'];
                $this->autoBuildVar($limit);
            } else {
                $limit = "'{$tag['limit']}'";
            }
        }else{
            $limit = '0,6';
        }
        $parse = <<<parse
<?php
    \$$name = \app\common\model\Article::tagArticle([
    'field'   => {$field},
    'cid'=>{$cid},
    'limit'=>{$limit},
    'flag'=>{$flag},
    'type'=>{$type},
    'order'=>{$order}
]);
?>
{volist name="{$name}" id="{$id}"}
{$content}
{/volist}
parse;
        return $parse;
    }

    /**
     * 广告标签
     * @param $tag
     * @return mixed
     */
    public function tagShow($tag)
    {
        $title = $tag['title'] ? $tag['title'] : '';
        $result = Db::name('ad')->where(['tag'=>$title, 'status'=>1])->find();
        return $result['content'];
    }

}

- 阅读剩余部分 -

lamp linux centos升级php5.4到5.6

升级编译参数

./configure --prefix=/usr/local/php56 \
--with-config-file-path=/usr/local/php56/etc \
--with-bz2 \
--with-curl \
--enable-ftp \
--enable-sockets \
--disable-ipv6 \
--with-gd \
--with-jpeg-dir=/usr/local \
--with-png-dir=/usr/local \
--with-freetype-dir=/usr/local \
--enable-gd-native-ttf \
--with-iconv-dir=/usr/local \
--enable-mbstring \
--enable-calendar \
--with-gettext \
--with-ldap \
--with-libxml-dir=/usr/local \
--with-zlib \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-mysql=mysqlnd \
--enable-dom \
--enable-xml \
--enable-fpm \
--enable-bcmath \
--enable-pcntl \
--with-mhash \
--enable-zip \
--with-openssl \
--enable-opcache \
--with-pear \
--with-apxs2=/usr/local/apache2/bin/apxs

PHP下载微信头像 微信活动海报

最近搞一个微信分享吸粉的活动,需要生成用户推广海报,使用TP的图像处理类可轻易添加昵称、图片、二维码等水印信息。但在生成此海报时,由于下载微信头像到本地/服务器用时太长,导致海报生成时间过长问题。

解决方法
使用curl压缩下载图片,加速图片下载速度,实现海报生成速度由8s左右到1s的提升。

- 阅读剩余部分 -

UUID简介

UUID 通用唯一识别码(Universally Unique Identifier)其目的,是让分布式系统中的所有元素,都能有唯一的辨识信息,而不需要通过中央控制端来做辨识信息的指定。

UUID是指在一台机器上生成的数字,它保证对在同一时空中的所有机器都是唯一的。通常平台会提供生成的API。按照开放软件基金会(OSF)制定的标准计算,用到了以太网卡地址、纳秒级时间、芯片ID码和许多可能的数字。

- 阅读剩余部分 -