2017 © Pedro Peláez
 

library thefairlib

这个类库只能用于与Yaf框架

image

lmz/thefairlib

这个类库只能用于与Yaf框架

  • Monday, June 4, 2018
  • by liumingzhij26
  • Repository
  • 2 Watchers
  • 2 Stars
  • 90 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 53 Versions
  • 53 % Grown

The README.md

说明,兼容php7.0+

老版本请使用:"lmz/thefairlib": "^2.0"

{
  "config": {"vendor-dir": "vendor"},
  "require": {
    "lmz/thefairlib": "*"
  },
  "repositories": {
    "packagist": {
      "type": "composer",
      "url": "https://packagist.phpcomposer.com"
    }
  }
}

TheFairLib 是基于yaf框架,集成了一些基本的类, (*1)

  • 阿里云OSS,使用成本很低,非常实用,个人站点的js,css,image都可以用的, (*2)

  • BigPipe 主要用于h5页面, (*3)

  • DB操作使用 predis / illuminate/database, (*4)

  • App的IM接入了融云, (*5)

  • App的消息推送,接入个推/极光, (*6)

  • 消息列表使用接入rabbitMq, (*7)

  • 全文搜索使用solr/es, (*8)

  • RPC服务器,使用swoole, (*9)

  • 后台或h5使用smarty模板,已升级到最新, (*10)

  • 验证码支持图片/短信验证码,只支持redis,短信目前只接入了云片网, (*11)

  • 微信营销接入有赞, (*12)

  • 工具库,支持汉字转拼音,能满足基本需求, (*13)

阿里云OSS上传

config目录下新建AliYun.php文件,不能使用其他名称, (*14)

<?php

/**
 * 阿里云CDN配置文件
 *
 * @author mingzhil
 * @mail liumingzhij26@qq.com
 */
namespace config;

class AliYun
{
    /**
     * 只允许修改参数,其他不能改变
     */
    public $OSS = [
        'OSS_ACCESS_ID' => '**********',
        'OSS_ACCESS_KEY' => '************',
        'OSS_ENDPOINT' => 'oss-cn-beijing.aliyuncs.com',
        'OSS_TEST_BUCKET' => 'static-pub',
        'ALI_LOG' => false,
        'ALI_DISPLAY_LOG' => false,
        'ALI_LANG' => 'zh',
    ];
}

Demo, (*15)

$file = new TheFairLib\Aliyun\AliOSS\Upload('file', [
    "host" => 'http://static.biyeyuan.com/',//CDN的域名、、
    "savePath" => '/tmp',//上传文件的路径
    "ossPath" => APP_NAME,//项目名称,也就是自定义阿里云目录
    "maxSize" => 2000, //单位KB
    "allowFiles" => [".gif", ".png", ".jpg", ".jpeg", ".bmp", ".css", ".js"]
]);
$data = $file->getFileInfo();
\Response\Response::Json($data);

验证码使用

font目录, (*16)

  • 只需要将字体放到font目录下,使用数字顺序命名,即可
  • 默认随机字体

Demo, (*17)

输出验证码, (*18)

$code = new \TheFairLib\Verify\Image();
$code->type = 'code';//类型,如login,reg,bind
$code->output(1);

查看或验证, (*19)

$code = new \TheFairLib\Verify\Image();
$code->type = 'code';
$code->validate($_GET['code']);
echo $code->getCode();

上传普通文件

Demo, (*20)

$file = new TheFairLib\Uploader\Upload('files', [
    "savePath" => '/tmp',//上传文件的路径
    "maxSize" => 2000, //单位KB
    "allowFiles" => [".gif", ".png", ".jpg", ".jpeg", ".bmp", ".css", ".js"]
]);
$status = $file->getFileInfo();

引入smarty模板

在yaf中的plugin目录下新建一下Tpl.php文件, (*21)

<?php
use Yaf\Plugin_Abstract;
use Yaf\Request_Abstract;
use Yaf\Response_Abstract;
use Yaf\Registry;
use Yaf\Dispatcher;

class TplPlugin extends Plugin_Abstract
{

    /**
     * 路由结束之后触发       此时路由一定正确完成, 否则这个事件不会触发
     *
     * @param Request_Abstract $request
     * @param Response_Abstract $response
     * @return mixed|void
     */
    public function routerShutdown(Request_Abstract $request, Response_Abstract $response)
    {
        $config = Registry::get("config")->smarty->toArray();
        $config['template_dir'] = $config['template_dir'] . $request->module . '/';
        $smarty = new TheFairLib\Smarty\Adapter(null, $config);
        Dispatcher::getInstance()->setView($smarty);
    }

}

在Bootstrap.php中挂起插件, (*22)

/**
 * 加载插件
 * @param \Yaf\Dispatcher $dispatcher
 */
public function _initPlugin(Yaf\Dispatcher $dispatcher)
{
    $dispatcher->registerPlugin(new TplPlugin());
}

发送短信验证码

config目录下新建Verify.php文件,不能使用其他名称,使用之前请将服务器加入白名单中, (*23)

<?php
namespace config;

class Verify
{


    /**
     * 默认手机验证码提供商云片网
     *
     * @var string
     */
    public $mobileVerify = [
        'name' => 'YunPian',
    ];

    /**
     * 手机验证码提供商
     *
     * @var array
     */
    public $mobileVerifyList = [
        'YunPian',

    ];
    public $appKey = [
        'YunPian' => [
            'key' => '***11e86244daa8fe53c14e5fcc14edfa1d***'
        ]
    ];

}

Demo, (*24)

TheFairLib\Verify\Mobile::Instance()->sendMessage('18888888888','您的验证码是'.mt_rand(1000,9999));

返回结果
{
    code: 0,
    msg: "OK",
    result: {
    count: 1,
        fee: 1,
        sid: 3489475182
    }
}

The Versions

13/04 2017

v2.0.20

2.0.20.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

29/03 2017

v2.0.19

2.0.19.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

27/02 2017

v2.0.18

2.0.18.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

24/02 2017

v2.0.17

2.0.17.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

16/01 2017

v2.0.16

2.0.16.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

16/01 2017

v2.0.15

2.0.15.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

16/01 2017

v2.0.14

2.0.14.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

29/12 2016

v2.0.13

2.0.13.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

04/12 2016

v2.0.12

2.0.12.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

30/08 2016

v2.0.11

2.0.11.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

30/08 2016

v2.0.10

2.0.10.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

14/08 2016

v2.0.9

2.0.9.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

08/08 2016

v2.0.8

2.0.8.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

30/07 2016

v2.0.7

2.0.7.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

17/07 2016

v2.0.6

2.0.6.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

17/07 2016

v2.0.5

2.0.5.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

14/07 2016

v1.1.1

1.1.1.0 https://github.com/liumingzhij26/thefairlib

这个类库只能用于与Yaf框架

  Sources   Download

MIT

The Requires

 

by mingzhi

thefair

28/06 2016

v2.0.4

2.0.4.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

15/06 2016

v2.0.3

2.0.3.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

15/06 2016

v2.0.2

2.0.2.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

15/06 2016

v2.0.1

2.0.1.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

14/06 2016

v2.0.0

2.0.0.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

13/05 2016

v1.0.63

1.0.63.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

13/05 2016

v1.0.62

1.0.62.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

13/05 2016

v1.0.60

1.0.60.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

11/05 2016

v1.0.59

1.0.59.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

09/05 2016

v1.0.58

1.0.58.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

05/05 2016

v1.0.57

1.0.57.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

04/05 2016

v1.0.56

1.0.56.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

29/04 2016

v1.0.55

1.0.55.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

29/04 2016

v1.0.54

1.0.54.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

28/04 2016

v1.0.53

1.0.53.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

28/04 2016

v1.0.52

1.0.52.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

28/04 2016

v1.0.51

1.0.51.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

28/04 2016

v1.0.50

1.0.50.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

27/04 2016

v1.0.49

1.0.49.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

25/04 2016

v1.0.48

1.0.48.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

14/04 2016

v1.0.47

1.0.47.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

14/04 2016

v1.0.46

1.0.46.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

05/04 2016

v1.0.45

1.0.45.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

27/03 2016

v1.0.44

1.0.44.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

24/03 2016

v1.0.43

1.0.43.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

24/03 2016

v1.0.42

1.0.42.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

24/03 2016

v1.0.41

1.0.41.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

23/03 2016

v1.0.4

1.0.4.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

23/03 2016

v1.0.3

1.0.3.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

22/03 2016

v1.0.2

1.0.2.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

20/03 2016

v1.0.1

1.0.1.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair

13/10 2015

v1.0.0

1.0.0.0 https://github.com/thefair-net/thefairlib

The PHP library for TheFair

  Sources   Download

MIT

The Requires

 

by Zhang Han

thefair