​​​​ 有用的PHP项目收集 | 苏生不惑的博客

有用的PHP项目收集

excel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
composer require maatwebsite/excel

composer require box/spout
php artisan make:command ExcelReader
<?php

namespace App\Console\Commands;

use App\Imports\TestImport;
use Box\Spout\Common\Type;
use Box\Spout\Reader\ReaderFactory;
use Illuminate\Console\Command;
use Maatwebsite\Excel\Facades\Excel;
use PhpOffice\PhpSpreadsheet\Settings;

class ExcelReader extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'excel:reader {path} {--drive=laravel-excel}';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* 测试文件的行数
* @var int
*/
private $rows = 0;

/**
* 程序运行消耗的时间(s)
* @var int
*/
private $timeUsage = 0;

/**
* 程序运行消耗的内存(byte)
* @var int
*/
private $memoryUsage = 0;

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* @throws \Exception
*/
public function handle()
{
$path = $this->argument('path');
$option = $this->option('drive');

switch ($option) {
case 'laravel-excel':
$this->useLaravelExcelDrive($path);
break;
case 'spout':
$this->useSpoutDrive($path);
break;
default:
throw new \Exception('Invalid option ' . $option);
}

$this->info(sprintf('共读取数据:%s 行', $this->rows));
$this->info(sprintf('共耗时:%s秒', $this->timeUsage));
$this->info(sprintf('共消耗内存: %sM', $this->memoryUsage / 1024 / 1024));
}

private function useSpoutDrive($path)
{
ini_set('memory_limit', -1);
$start = now();
$reader = ReaderFactory::create(Type::XLSX);
$reader->setShouldFormatDates(true);
$reader->open(storage_path('app/'.$path));
$rows = [];
foreach ($reader->getSheetIterator() as $sheet) {
foreach ($sheet->getRowIterator() as $row) {
$this->rows++;
$rows[] = $row;
}
}
$this->timeUsage = now()->diffInSeconds($start);
$this->memoryUsage = xdebug_peak_memory_usage();
}

private function useLaravelExcelDrive($path)
{
$start = now();
Settings::setLibXmlLoaderOptions(LIBXML_COMPACT | LIBXML_PARSEHUGE);
ini_set('memory_limit', -1);
$array = Excel::toArray(new TestImport(), $path);
$this->rows = count($array[0]);
$this->timeUsage = now()->diffInSeconds($start);
$this->memoryUsage = xdebug_peak_memory_usage();
}
}
php artisan make:import TestImport
<?php

namespace App\Imports;

use Illuminate\Support\Collection;
use Maatwebsite\Excel\Concerns\ToArray;
use Maatwebsite\Excel\Concerns\ToCollection;
use Maatwebsite\Excel\Concerns\WithChunkReading;

class TestImport
{

}
php artisan excel:read public/test.xlsx
php artisan excel:read public/test.xlsx --drive=spout

B 站直播实用脚本

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
$ git clone https://github.com/metowolf/BilibiliHelper.git
$ cd BilibiliHelper
$ cp config.example config
$ composer install
$ php index.php
[2018-12-12 13:58:33] Bilibili.DEBUG: POST: https://api.live.bilibili.com/User/userOnlineHeart
[2018-12-12 13:58:33] Bilibili.DEBUG: {"code":0,"msg":"OK","message":"OK","data":{"giftlist":[]}}
[2018-12-12 13:58:33] Bilibili.INFO: 向直播间 3746256 发送心跳包 (web)
[2018-12-12 13:58:33] Bilibili.DEBUG: POST: https://api.live.bilibili.com/mobile/userOnlineHeart
[2018-12-12 13:58:33] Bilibili.DEBUG: {"code":0,"msg":"OK","message":"OK","data":{"giftlist":[]}}
[2018-12-12 13:58:33] Bilibili.INFO: 向直播间 3746256 发送心跳包 (APP)
[2018-12-12 13:58:33] Bilibili.DEBUG: GET: https://api.live.bilibili.com/lottery/v1/SilverBox/getCurrentTask
[2018-12-12 13:58:33] Bilibili.DEBUG: {"code":0,"msg":"","message":"","data":{"minute":3,"silver":30,"time_start":1544594312,"time_end":1544594492,"times":1,"max_times":3}}
[2018-12-12 13:58:33] Bilibili.NOTICE: 领取宝箱成功,内含 30 个瓜子
[2018-12-12 13:58:33] Bilibili.INFO: 等待 3 分钟后打开宝箱
[2018-12-12 13:58:33] Bilibili.INFO: 检查每日任务
# vi /usr/lib/systemd/system/bilibili.service

[Unit]
Description=Bilibili Helper Manager
Documentation=https://github.com/metowolf/BilibiliHelper
After=network.target

[Service]
ExecStart=/usr/bin/php /root/BilibiliHelper/index.php
Restart=always

[Install]
WantedBy=multi-user.target

$ systemctl restart bilibili
[root@VM_0_14_centos BilibiliHelper]# ps aux|grep bili|grep -v grep
root 7987 1.6 1.0 317640 19012 ? Ss 14:03 0:00 /usr/bin/php /root/BilibiliHelper/index.php

XSS Platform

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//https://laravel-china.org/articles/20815
#git clone https://github.com/78778443/xssplatform.git
#vi /etc/nginx/nginx.conf
server {
listen 80;
server_name xss.localhost;
root /Users/song/mycode/safe/xssplatform/;

rewrite "^/([0-9a-zA-Z]{6})$" /index.php?do=code&urlKey=$1 last;
rewrite "^/do/auth/(\w+?)(/domain/([\w\.]+?))?$" /index.php?do=do&auth=$1&domain=$3 last;
rewrite "^/register/(.*?)$" /index.php?do=register&key=$1 last;
rewrite "^/register-validate/(.*?)$" /index.php?do=register&act=validate&key=$1 last;

location / {

index index.html index.htm index.php;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

}
#nginx -s reload

生成小程序图文海报

1
2
3
4
5
6
7
8
9
10
11
12
https://laravel-china.org/articles/18418
composer require ibrand/laravel-miniprogram-poster
低于 Laravel5.5 版本,config/app.php 文件中 'providers' 添加iBrand\Poster\PhantoMmagickServiceProvider::class

图片保存在 storage/app/public 下所以需要执行 php artisan storage:link

如需自定义配置请执行 php artisan vendor:publish --provider="iBrand\Poster\PhantoMmagickServiceProvider" --tag="config"

use iBrand\Miniprogram\Poster\MiniProgramShareImg;

$url = 'https://www.ibrand.cc/';
$result = MiniProgramShareImg::generateShareImage($url);

HTML 导出 PDF

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
//https://laravel-china.org/articles/21905 https://github.com/niklasravnsborg/laravel-pdf
下载 https://wkhtmltopdf.org/downloads.html
wkhtmltopdf https://www.baidu.com 1.pdf
$ wkhtmltopdf.exe --lowquality "http://www.baidu.com" baidu.pdf
Loading pages (1/6)
libpng warning: iCCP: known incorrect sRGB profile ] 35%
libpng warning: iCCP: known incorrect sRGB profile ] 41%
libpng warning: iCCP: known incorrect sRGB profile ] 46%
Counting pages (2/6)
Resolving links (4/6)
Loading headers and footers (5/6)
Printing pages (6/6)
Done

composer require barryvdh/laravel-snappy

将ServiceProvider添加到config / app.php中的providers数组
Barryvdh\Snappy\ServiceProvider::class,

添加facadeconfig / app.php中的aliases数组中
'PDF' => Barryvdh\Snappy\Facades\SnappyPdf::class,
'SnappyImage' => Barryvdh\Snappy\Facades\SnappyImage::class,

生成配置文件
php artisan vendor:publish --provider="Barryvdh\Snappy\ServiceProvider"
vi config/snappy.php
binary=>'D:\laragon\www\source\wkhtmltopdf\bin\wkhtmltopdf.exe'
# 下载
$pdf = \PDF::loadView('welcome', $data);
return $pdf->download('welcome.pdf');

# 渲染页面
$html = '<html><head><meta charset="utf-8"></head><h1>订单id</h1><h2>12346546</h2></html>';
$pdf = \PDF::loadHTML($html);
return $pdf->inline();

$pdf = \App::make('snappy.pdf.wrapper');
$pdf->loadHTML('<h1>Test</h1>');
return $pdf->inline();

return PDF::loadFile('http://www.github.com')->inline('github.pdf');
$snappy = \App::make('snappy.pdf');
//To file
$html = '<h1>Bill</h1><p>You owe me money, dude.</p>';
$snappy->generateFromHtml($html, '/tmp/bill-123.pdf');
$snappy->generate('http://www.github.com', '/tmp/github.pdf');

#门面(facade)加载HTML字符串、文件或者视图
#stream()方法显示在浏览器中
#save()方法保存到文件
#download()方法下载

$pdf = PDF::loadView('pdf.invoice', $data);
return $pdf->download('invoice.pdf');

#链式操作
return PDF::loadFile('file.html')->save('file.pdf')->stream('download.pdf');

#方向
PDF::loadHTML($html)->setPaper('a4', 'landscape')->setWarnings(false)->save('file.pdf')

#生成图片
$pdf = SnappyImage::loadView('pdf.invoice', $data);
return $pdf->download('invoice.image');
https://php1024.com/posts/45.htm

zip

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//https://laravel-china.org/topics/21368
composer require chumper/zipper
$zipper = new \Chumper\Zipper\Zipper;
// https://github.com/Chumper/Zipper https://github.com/Ne-Lexa/php-zip
$zipper->make('test.zip')->folder('test')->add('composer.json');
$zipper->zip('test.zip')->folder('test')->add('composer.json','test');

$zipper->remove('composer.lock');

$zipper->folder('mySuperPackage')->add(
array(
'vendor',
'composer.json'
),
);

$zipper->getFileContent('mySuperPackage/composer.json');

$zipper->make('test.zip')->extractTo('',array('mySuperPackage/composer.json'),Zipper::WHITELIST);

$zipper->close();

Walle-瓦力上线部署系统正确安装

1
2
3
https://www.phpsong.com/2166.html
mkdir -p /data/www/walle-web && cd /data/www/walle-web # 新建目录
git clone git@github.com:meolu/walle-web.git . # 代码检出

api文档swagger

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//https://github.com/zircote/swagger-php
$ composer global require zircote/swagger-php
Changed current directory to C:/Users/suping3/AppData/Roaming/Composer
1/2: https://packagist.laravel-china.org/p/provider-latest$37c8735b09b76040c9a255538c478903f6395d36efb59ce8ad13018c0e87dea7.json
2/2: https://packagist.laravel-china.org/p/provider-2018-10$6a20a9e7d4e44c231d13cc94ff3b58d88abbec0d6ca0a8aa8e2178d4569d0ea4.json
Finished: success: 2, skipped: 0, failure: 0, total: 2
Using version ^3.0 for zircote/swagger-php
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing zircote/swagger-php (3.0.2): Loading from cache
Writing lock file
Generating autoload files

suping3@BJ-D-212361A MINGW64 /d/php_study/PHPTutorial/WWW/laravel
$ vendor/bin/openapi --help

Usage: openapi [--option value] [/path/to/project ...]

Options:
--output (-o) Path to store the generated documentation.
ex: --output openapi.yaml
--exclude (-e) Exclude path(s).
ex: --exclude vendor,library/Zend
--bootstrap (-b) Bootstrap a php file for defining constants, etc.
ex: --bootstrap config/constants.php
--processor Register an additional processor.
--format Force yaml or json.
--debug Show additional error information.
--help (-h) Display this help message.

手机上利用PHP完成对电脑的操作

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//http://www.helpergarden.com/2014/03/%e5%9c%a8%e6%89%8b%e6%9c%ba%e4%b8%8a%e5%88%a9%e7%94%a8php%e5%ae%8c%e6%88%90%e5%af%b9%e7%94%b5%e8%84%91%e7%9a%84%e6%93%8d%e4%bd%9c.html
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
a{font-size: 32px;}
</style>
<a href="?type=cancle">取消关机</a>
<br><br>
<a href="?type=close">关机</a>
<?php
$type=isset($_GET['type'])?$_GET['type']:false;
$cmd='';
switch ($type){
case 'cancle':
$cmd="shutdown -a";
break;
case 'close':
$cmd="shutdown -f -s -t 120";
break;
default:
$cmd='';
break;
}
if(!empty($cmd))
exec($cmd);
?>

隐藏你的 ID

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
//https://laravel-china.org/articles/18335
composer require 96qbhy/hyid
php artisan vendor:publish --provider=Qbhy\Hyid\ServiceProvider
class User extends Model{
use Qbhy\Hyid\HyidAble;

// or
public function getUserId($userId){
return hyid($userId);
}

// or
public function toArray(){
$data = parent::toArray();

$data['id'] = hyid()->encode($data['id'])

return $data;
}
}
// decode
public function userinfo($id){
return User::query()->findOrFail(hyid()->decode($id))->toArray();
}
// 非 laravel or lumen 下,可以自行实例化 Hyid 类
$secret = 'qbhy';
$offset = 1996;
$randomLength = 6;
$hyid = new Hyid($secret,$offset,$randomLength);

$encodedId = $hyid->encode(1);
$id = $hyid->decode($encodedId);

书童机器人

1
2
3
4
5
6
https://laravel-china.org/articles/6429/lang-jelly-robot-chat-with-you
$ git clone https://github.com/jormin/robot.git
$ composer install
$ cd /path/to/robot
$ cp .env.example .env
$ php artisan key:generate

格式化sql

1
2
3
4
5
6
7
8
9
require_once('SqlFormatter.php');
//https://github.com/jdorn/sql-formatter/blob/master/lib/SqlFormatter.php
$query = "SELECT count(*),`Column1`,`Testing`, `Testing Three` FROM `Table1`
WHERE Column1 = 'testing' AND ( (`Column2` = `Column3` OR Column4 >= NOW()) )
GROUP BY Column1 ORDER BY Column3 DESC LIMIT 5,10";

echo SqlFormatter::format($query);
echo SqlFormatter::format($query, false);
echo SqlFormatter::compress($query);

jwt

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
namespace App;
class JwtBase {
//头部
private static $header=array(
'alg'=>'HS256', //生成signature的算法
'typ'=>'JWT' //类型
);
//使用HMAC生成信息摘要时所使用的密钥
private static $key='KEY';

/**
* 获取jwt token
* @param array $payload jwt载荷 格式如下非必须
* [
* 'iss'=>'jwt_admin', //该JWT的签发者
* 'iat'=>time(), //签发时间
* 'exp'=>time()+7200, //过期时间
* 'nbf'=>time()+60, //该时间之前不接收处理该Token
* 'sub'=>'www.admin.com', //面向的用户
* 'jti'=>md5(uniqid('JWT').time()) //该Token唯一标识
* ]
* @return bool|string
*/
public static function getToken(array $payload)
{
$arr = [
'iss'=>'yamecent', //该JWT的签发者
'iat'=>time(), //签发时间
'exp'=>time()+3600*24*15, //过期时间
'nbf'=>time(), //该时间之前不接收处理该Token
'sub'=>'', //面向的用户
'jti'=>md5(uniqid('JWT').time()) //该Token唯一标识
];
$payload = array_merge($arr,$payload);
if(is_array($payload))
{
$base64header=self::base64UrlEncode(json_encode(self::$header,JSON_UNESCAPED_UNICODE));
$base64payload=self::base64UrlEncode(json_encode($payload,JSON_UNESCAPED_UNICODE));
$token=$base64header.'.'.$base64payload.'.'.self::signature($base64header.'.'.$base64payload,self::$key,self::$header['alg']);
return $token;
}else{
return false;
}
}

/**
* 验证token是否有效,默认验证exp,nbf,iat时间
* @param string $Token 需要验证的token
* @return bool|string
*/
public static function verifyToken(string $Token)
{
$tokens = explode('.', $Token);
if (count($tokens) != 3)
return false;

list($base64header, $base64payload, $sign) = $tokens;

//获取jwt算法
$base64decodeheader = json_decode(self::base64UrlDecode($base64header), JSON_OBJECT_AS_ARRAY);
if (empty($base64decodeheader['alg']))
return false;

//签名验证
if (self::signature($base64header . '.' . $base64payload, self::$key, $base64decodeheader['alg']) !== $sign)
return false;

$payload = json_decode(self::base64UrlDecode($base64payload), JSON_OBJECT_AS_ARRAY);

//签发时间大于当前服务器时间验证失败
if (isset($payload['iat']) && $payload['iat'] > time())
return false;

//过期时间小宇当前服务器时间验证失败
if (isset($payload['exp']) && $payload['exp'] < time())
return false;

//该nbf时间之前不接收处理该Token
if (isset($payload['nbf']) && $payload['nbf'] > time())
return false;

return $payload;
}

/**
* base64UrlEncode https://jwt.io/ 中base64UrlEncode编码实现
* @param string $input 需要编码的字符串
* @return string
*/
private static function base64UrlEncode(string $input)
{
return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
}

/**
* base64UrlEncode https://jwt.io/ 中base64UrlEncode解码实现
* @param string $input 需要解码的字符串
* @return bool|string
*/
private static function base64UrlDecode(string $input)
{
$remainder = strlen($input) % 4;
if ($remainder) {
$addlen = 4 - $remainder;
$input .= str_repeat('=', $addlen);
}
return base64_decode(strtr($input, '-_', '+/'));
}

/**
* HMACSHA256签名 https://jwt.io/ 中HMACSHA256签名实现
* @param string $input 为base64UrlEncode(header).".".base64UrlEncode(payload)
* @param string $key
* @param string $alg 算法方式
* @return mixed
*/
private static function signature(string $input, string $key, string $alg = 'HS256')
{
$alg_config=array(
'HS256'=>'sha256'
);
return self::base64UrlEncode(hash_hmac($alg_config[$alg], $input, $key,true));
}
}
$token = \App\JwtBase::getToken(['user_id'=>666]);//生成token
$data = \App\JwtBase::verifyToken($token);
dump($data);
array:7 [▼
"iss" => "yamecent"
"iat" => 1547186866
"exp" => 1548482866
"nbf" => 1547186866
"sub" => ""
"jti" => "fbb7cbfd4f962dfb6ff193e28f09b6e2"
"user_id" => 666
]

php版为所欲为

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
# 安装 epel 库,如果以前装过可以不用
yum install -y epel-release

# 引入 nux.ro 的库
rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm

# 执行安装
yum install ffmpeg

摘抄自:https://sendya.me/centos-yum-install-ffmpeg-lib/
安装字体 https://blog.csdn.net/wlwlwlwl015/article/details/51482065
git clone https://github.com/PrintNow/php-sorry-gif
cd php-sorry-gif
ps aux |grep fpm
chown -R nobody:nobody /usr/share/nginx/html/php-sorry-gif/
访问 http://118.24.158.116:8888/php-sorry-gif/index.php#weisuoyuwei

js 版
$ git clone https://github.com/WincerChan/Meme-generator
Cloning into 'Meme-generator'...
remote: Enumerating objects: 30, done.
remote: Counting objects: 100% (30/30), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 488 (delta 13), reused 22 (delta 7), pack-reused 458
Receiving objects: 100% (488/488), 7.50 MiB | 545.00 KiB/s, done.
Resolving deltas: 100% (280/280), done.


$ cd Meme-generator/


$ yarn install
yarn install v1.9.4
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.2.4: The platform "win32" is incompatible with this module.
info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 50.18s.


$ yarn start
yarn run v1.9.4
$ react-scripts start
Starting the development server...

Compiled successfully!

You can now view meme in the browser.

Local: http://localhost:3000/
On Your Network: http://10.235.51.40:3000/

Note that the development build is not optimized.
To create a production build, use yarn build.

python 版

$ pip install flask pillow imageio ffmpeg-python moviepy
Requirement already satisfied: flask in d:\python\lib\site-packages (0.12.4)
Collecting pillow
Downloading https://files.pythonhosted.org/packages/d7/ea/46fd5bd57c5df5a2e79e508294acec4be0fcc2fb3ce95c2cf1038ebaa533/Pillow-5.4.1-cp37-cp37m-win32.whl (1.7MB)
Collecting imageio
Downloading https://files.pythonhosted.org/packages/28/b4/cbb592964dfd71a9de6a5b08f882fd334fb99ae09ddc82081dbb2f718c81/imageio-2.4.1.tar.gz (3.3MB)
Collecting ffmpeg-python
Downloading https://files.pythonhosted.org/packages/3d/10/330cbc8e63d072d40413f4d470444a6a1e8c8c6a80b2a4ac302d1252ca1b/ffmpeg_python-0.1.17-py3-none-any.whl
Collecting moviepy
Downloading https://files.pythonhosted.org/packages/1f/af/98b68b047c47d9430cb4c9ac899cf9d969de3936f888072991ea74da93a8/moviepy-0.2.3.5.tar.gz (372kB)
Requirement already satisfied: click>=2.0 in d:\python\lib\site-packages (from flask) (6.7)
Requirement already satisfied: Jinja2>=2.4 in d:\python\lib\site-packages (from flask) (2.10)
Requirement already satisfied: Werkzeug>=0.7 in d:\python\lib\site-packages (from flask) (0.14.1)
Requirement already satisfied: itsdangerous>=0.21 in d:\python\lib\site-packages (from flask) (0.24)
Requirement already satisfied: numpy in d:\python\lib\site-packages (from imageio) (1.15.1)
Requirement already satisfied: future in d:\python\lib\site-packages (from ffmpeg-python) (0.16.0)
Requirement already satisfied: decorator<5.0,>=4.0.2 in d:\python\lib\site-packages (from moviepy) (4.3.0)
Collecting tqdm<5.0,>=4.11.2 (from moviepy)
Downloading https://files.pythonhosted.org/packages/d1/f9/8cbd36ef8bf84c5281e4943eaa12fe34850a0e8204e44872d8ca0c0ec741/tqdm-4.29.0-py2.py3-none-any.whl (46kB)
Requirement already satisfied: MarkupSafe>=0.23 in d:\python\lib\site-packages (from Jinja2>=2.4->flask) (1.0)
Building wheels for collected packages: imageio, moviepy
Running setup.py bdist_wheel for imageio: started
Running setup.py bdist_wheel for imageio: finished with status 'done'
Stored in directory: C:\Users\suping3\AppData\Local\pip\Cache\wheels\e0\43\31\605de9372ceaf657f152d3d5e82f42cf265d81db8bbe63cde1
Running setup.py bdist_wheel for moviepy: started
Running setup.py bdist_wheel for moviepy: finished with status 'done'
Stored in directory: C:\Users\suping3\AppData\Local\pip\Cache\wheels\ad\92\4d\a6c6307d4c2219d002646bd4a5987e31fd5697f6ea7778b2c0
Successfully built imageio moviepy
Installing collected packages: pillow, imageio, ffmpeg-python, tqdm, moviepy
Successfully installed ffmpeg-python-0.1.17 imageio-2.4.1 moviepy-0.2.3.5 pillow-5.4.1 tqdm-4.29.0

suping3@BJ-D-212361A MINGW64 /d/code/Meme-generator (master)
$ cd ..


$ git clone https://github.com/East196/sorrypy
Cloning into 'sorrypy'...
remote: Enumerating objects: 136, done.
remote: Total 136 (delta 0), reused 0 (delta 0), pack-reused 136
Receiving objects: 100% (136/136), 27.71 MiB | 230.00 KiB/s, done.
Resolving deltas: 100% (55/55), done.
Checking out files: 100% (48/48), done.


$ cd sorrypy/


$ python app.py
* Restarting with stat
* Debugger is active!
* Debugger PIN: 139-127-258
* Running on http://127.0.0.1:8000/ (Press CTRL+C to quit)
127.0.0.1 - - [11/Jan/2019 17:17:43] "GET / HTTP/1.1" 302 -
--------------------------------------------------------------------------------
DEBUG in app [app.py:18]:
sorry
--------------------------------------------------------------------------------
127.0.0.1 - - [11/Jan/2019 17:17:43] "GET /tpl/sorry/ HTTP/1.1" 200 -
127.0.0.1 - - [11/Jan/2019 17:17:43] "GET /static/w3.css HTTP/1.1" 200 -
127.0.0.1 - - [11/Jan/2019 17:17:43] "GET /static/cookies.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jan/2019 17:17:43] "GET /static/main.js HTTP/1.1" 200 -
127.0.0.1 - - [11/Jan/2019 17:17:43] "GET /static/sorry/template.mp4 HTTP/1.1" 200 -
127.0.0.1 - - [11/Jan/2019 17:17:43] "GET /favicon.ico HTTP/1.1" 404 -

采集数据

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
composer require jaeger/querylist
use QL\QueryList;

//采集某页面所有的图片
$data = QueryList::get('http://cms.querylist.cc/bizhi/453.html')->find('img')->attrs('src');
//打印结果
print_r($data->all());
array:38 [▼
0 => "/dedemao/images/logo.png"
1 => "/dedemao/ad/top.png"
2 => "/dedemao/ad/article_ad1.jpg"
3 => "http://img.ithome.com/newsuploadfiles/2013/8/20130828_083615_449.jpg"
//采集某页面所有的超链接和超链接文本内容
//可以先手动获取要采集的页面源码
$html = file_get_contents('http://cms.querylist.cc/google/list_1.html');
//然后可以把页面源码或者HTML片段传给QueryList
$data = QueryList::html($html)->rules([ //设置采集规则
// 采集所有a标签的href属性
'link' => ['a','href'],
// 采集所有a标签的文本内容
'text' => ['a','text']
])->query()->getData();
//打印结果
print_r($data->all());
array:186 [▼
0 => array:2 [▼
"link" => "/"
"text" => ""
]
1 => array:2 [▼
"link" => "/"
"text" => "首页"
]

###

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
docker pull hihozhou/opencv
git clone https://github.com/hihozhou/php-opencv.git
cd php-opencv
phpize
./configure --with-php-config=your php-config path
make
make install

use function CV\{ imread, imshow, waitkey, namedWindow};

$im = imread('Obama.png');//load image
namedWindow('This is Obama id card',WINDOW_FULLSCREEN);//create window
imshow('This is Obama id card',$im);//show image on window

waitkey(0);
$gray = imread('Obama.png',IMREAD_GRAYSCALE);
//or
use function CV\{ cvtColor};
$gray = cvtColor($im, COLOR_BGR2GRAY);

中国城市关联

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
$ composer require eachdemo/city-linkage:dev-master
# 发布资源文件
$ php artisan vendor:publish --provider="Eachdemo\CityLinkage\CityServiceProvider"
# 生成数据库 表
$ php artisan migrate
Schema::create('city_linkage', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->smallInteger('parent_id');
$table->string('pinyin');
$table->string('initial');
$table->string('initials');
$table->string('suffix');
$table->string('code');
$table->string('order');
});
# 填充表数据
$ php artisan db:seed --class=CitySeeder
In Container.php line 752:

Class CitySeeder does not exist
$ composer dump-autoload
Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: appstract/laravel-opcache
Discovered Package: appstract/lush-http
Discovered Package: barryvdh/laravel-dompdf
Discovered Package: barryvdh/laravel-snappy
Discovered Package: chumper/zipper
Discovered Package: darkaonline/l5-swagger
Discovered Package: eachdemo/city-linkage
Discovered Package: encore/laravel-admin
Discovered Package: fideloper/proxy
Discovered Package: ibrand/laravel-database-logger
Discovered Package: ibrand/laravel-miniprogram-poster
Discovered Package: intervention/image
Discovered Package: jellybool/flysystem-upyun
Discovered Package: laravel/passport
Discovered Package: laravel/socialite
Discovered Package: laravel/tinker
Discovered Package: maatwebsite/excel
Discovered Package: mews/captcha
Discovered Package: nesbot/carbon
Discovered Package: niklasravnsborg/laravel-pdf
Discovered Package: socialiteproviders/manager
Discovered Package: tumobi/qqmap-region
Discovered Package: tymon/jwt-auth
Discovered Package: vetor/laravel-collect
Discovered Package: wenslim/editormd
Discovered Package: zgldh/qiniu-laravel-storage
Package manifest generated successfully.
php artisan db:seed --class=CitySeeder 失败时可以执行先 composer dump-autoload 再执行 php artisan db:seed --class=CitySeeder 填充
<?php
namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Eachdemo\CityLinkage\CityLinkage;

class DataController extends Controller
{
public function test(){
$city = CityLinkage::getData(); # 获取所有省份城市
$city = CityLinkage::getData(1); # 获取北京市下所有区(北京id为1)
}
}

二维码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
composer require endroid/qr-code
//composer require simplesoftwareio/simple-qrcode

use Endroid\QrCode\QrCode;

$qrCode = new QrCode('Life is too short to be generating QR codes');

header('Content-Type: '.$qrCode->getContentType());
echo $qrCode->writeString();
composer require khanamiryan/qrcode-detector-decoder
use Zxing\QrReader;

$qrcode = new QrReader('path/to_image');
$text = $qrcode->text(); //return decoded text from QR Code

生成 API 文档

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
composer require wxm/ddoc --dev
php artisan vendor:publish --provider="Wxm\DDoc\DDocServiceProvider" --force
php artisan serve
http://localhost:8000/ddoc

vi routes/web.php
namespace App\Http\Controllers;
/**
* @Resource("登录令牌", uri="/token")
*/
class AuthController extends Controller
{
/**
* 获取令牌
*
* > 通过手机号和密码获取会话`token`即登录凭证.
* > 需要认证的请求请携带此 Authorization 头
* >
* > Authorization:Bearer {token}
* >
*
* @Post("/")
* @Versions({"v1"})
* @Response(200, body={"token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJodHRwOlwvXC9hcGkueHkudGVzdFwvc2Vzc2lvbiIsImlhdCI6MTU0NTIxNjM5OSwiZXhwIjoxNTQ1MjE5OTk5LCJuYmYiOjE1NDUyMTYzOTksImp0aSI6Im9pZjV4WTNqS2JkbEhzVmQiLCJzdWIiOjEsInBydiI6Ijg3ZTBhZjFlZjlmZDE1ODEyZmRlYzk3MTUzYTE0ZTBiMDQ3NTQ2YWEifQ.p3oAVkAxSCxTug5s6168N-ccfuCCywGDFiJ0b9zCXq8","token_type":"bearer","expires_in":3600})
* @Parameters({
* @Parameter("phone", type="integer", required=true, description="手机号."),
* @Parameter("password", type="string", required=true, description="密码."),
* })
*/
public function login()
{

}

生成identicon头像

1
2
3
4
5
6
7
8
composer require valiner/identicon-avatar
require __DIR__.'/vendor/autoload.php';

use Valiner\IdenticonAvatar\Identicon;

$identicon = new Identicon();
//浏览器输出'sdp'的125px的图像https://github.com/valiner/identicon-avatar
$identicon->getAvatar('sdp',125);

像 cms 一样安装 Laravel 项目

1
2
3
4
composer require rachidlaasri/laravel-installer
php artisan vendor:publish --tag=laravelinstaller
php artisan serve
localhost:8000/install update

全新 PHP 运行时环境

1
2
3
4
5
6
7
8
9
git clone https://github.com/polarphp/polarphp.git
cd polarphp
git submodule init
git submodule update
git checkout v0.0.1-alpha
./devtools/scripts/build_polarphp.sh

docker run --rm -it polarphp_debug
polar --version

url 生成二维码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
composer require "simplesoftwareio/simple-qrcode: ~2"
QrCode::generate('Make me into a QrCode!');
QrCode::generate('Make me into a QrCode!', '../public/qrcodes/qrcode.svg');
QrCode::encoding('UTF-8')->generate('Make me a QrCode with special symbols ♠♥!!');
QrCode::merge($filename, $percentage, $absolute);

//Generates a QrCode with an image centered in the middle.
QrCode::format('png')->merge('path-to-image.png')->generate();
QrCode::BTC($address, $amount);

//Sends a 0.334BTC payment to the address
QrCode::BTC('bitcoin address', 0.334);

//Sends a 0.334BTC payment to the address with some optional arguments
QrCode::size(500)->BTC('address', 0.0034, [
'label' => 'my label',
'message' => 'my message',
'returnAddress' => 'https://www.returnaddress.com'
]);
QrCode::email('foo@bar.com');
https://learnku.com/articles/19436#topnav

gif图片转字符

1
2
3
4
5
6
7
https://github.com/hit9/gif2txt
python gif2txt.py test.gif -m 80 -o examples/out.html
python gif2txt.py test.gif -m 80 -o examples/withcolor.html -c
python gif2txt.py pacman.gif -o examples/pacman.html -c --green-screen-sensibility 128
python gif2txt.py test.gif -r -o examples/reversegreenscreen.html

在线浏览动图https://hit9.github.io/gif2txt/examples/out.html

PHP 提取文章关键词

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
composer require fukuball/jieba-php:dev-master
<?php // index.php
include_once './vendor/autoload.php';

ini_set('memory_limit', '600M');

use Fukuball\Jieba\Jieba;
use Fukuball\Jieba\Finalseg;
use Fukuball\Jieba\JiebaAnalyse;

Jieba::init(array('mode' => 'test', 'dict' => 'small'));
Finalseg::init();
JiebaAnalyse::init();

$top_k = 10; // 获取前10个关键词
$content = file_get_contents('./test.txt');

$tags = JiebaAnalyse::extractTags($content, $top_k);

var_dump($tags);
https://blog.foof.dev/posts/php-0

音乐聚合搜索

php excel样式

快速Excel

微信跳一跳的 php 版本https://www.h57.pw/2018/01/05/use-php-to-achieve-wechat-jump-for-android-phones/

PHP 高效的开发量化数字货币交易程序 github.com/zhouaini528/exchanges-php

PHP实现PCM格式音波文件转WAV格式音频文件

搭建私有仓库

PHP 爬虫系统

PHP 最优秀资源的整理汇集

PHP火焰图工具,支持php7

将PHP语言打造成为一门真正的通用性脚本语言

API 接口设计规范

PhpSpreadsheet 简单 Excel 导入导出

阅读过的干货文章

生成 API https://laravel.com/api/5.7/index.html

有 if 一定要有 else

Dokuwiki 二次开发记录

Laravel5.5 支付宝支付

php函数

Windows 下最详细的源码编译 PHP 以及 PHP 扩展

在线采集数据

PHP 多接口获取快递物流信息包

私有云服务器

基于redis实现高可用,易拓展,接入方便,生产环境稳定运行的延迟队列

JWT 超详细分析

Laravel 5 中使用 JWT

别再这样使用JWT了!

PHP 编写的多进程网络爬虫框架

laravel扩展包——laravel-dompdf和laravel-snappy

laravel中进行PDF导出遇到的问题

解决larave-dompdf中文字体显示问题

关于 DomPDF 导出中文乱码问题

Web 安全之 XSS Platform 搭建及使用实践

PHP比特币开发系列教程汇总

中国(大陆)公民身份证类

消息推送系统

Laravel 深入浅出指南

implode.io 记录分享你的代码片段

小程序社区

php以太坊

聊天应用

数据字典自动生成文档

PHPer的面试总结

方便 PHPer,Laraveler 测试代码的有用工具

30s php

巧用 PHP 数组函数

Snowflake 生成分布式唯一 ID

ZipArchive 解压中文文件乱码

简聊 Session 与 Token 身份验证

基于阿里云短信服务的 PHP 扩展包

中国标准行政区划数据

实用 Markdown 编辑器

你可能不太需要 Laravel-Excel

Laravel HTML 导出 PDF 方案 —– wkhtmltopdf Laravel-snappy

php-rdkafka

laravel Swagger

在线制作 sorry 为所欲为

nginx 实现动态生成缩略图

PHP 处理kafka消息实例

一个PHP文件搞定支付宝支付系列

PHP下kafka的实践

使用PHP处理Kafka消息

Kafka-php

基于 Laravel 可灵活自定义的的私人微信机器人

简单轻松部署你的项目 - Deployer

PHP 资源列表大全

php面向对象

百度AI开放平台 PHP SDK

阿里云短信服务的 PHP 扩展包

PHP使用QueryList采集微信文章页

PHP人工智能

PHP 编写的聊天软件

PHP爬虫框架

支付系统

php leetcode

在线测试PHP

JWT 超详细分析

PHP 面试常考内容之面向对象

PHP性能监控问题记录之一-安装配置php-apm

PHP实现 手机号码归属地查询

Nginx to PHP-FPM

编程浪子开源云客服

音乐api

帮助个人开发者在线收款的接口服务

爬虫框架

PHP下载音乐

web即时聊天

替代serialize的扩展igbinary

Docker+Nginx+MySQL+PHP (xhprof、tideways)+xhgui开发环境

PHP 并发场景

多站合一音乐搜索解决方案

构建命令行工具的库

PHP版本的 Redis命令行客户端

个人微信模板信息推送

av电影管理系统https://github.com/hldh214/gas

SQL 语句优化器和重写器的 PHP 扩展包

不一样的PHP工具类

php视频网站

画江湖之算法篇

91porn爬虫php版本