php

PhpStorm 配置 Xdebug 3,及常见问题

php

做PHP开发也很多年了,Xdebug也配过很多次,但总觉得不是刚需,感觉有没有都行;另一方面它配置复杂(新方法很简单),每个项目都得配一遍(新方法也避免不了),并且在公司配完,回到家还得修改hosts 中的ip(新方法不需要)。种种原因,使用Xdebug的习惯并没有延续下来。直到我近日接触了yii2中的事件,比如: $config = [ 'components' => [ ... ], 'on beforeRequest' => function($event) { \yii\base\Event::on(\yii\db\BaseActiveRecor...

yii2-queue队列的使用

php

安装 composer require yiisoft/yii2-queue 配置 //cat config/console.php return [ 'bootstrap' => [ 'queue', ], 'components' => [ 'redis' => [ 'class' => 'yii\redis\Connection', 'hostname' => 'docker-redis', 'port' => 6379, 'datab...

laravel 调试工具

php

Laravel-debugbar 可以打印出每个请求执行的sql 安装 composer require barryvdh/laravel-debugbar 执行完即可,打开任一html页面(返回json的不行) 更详细的说明请参考:https://github.com/barryvdh/laravel-debugbar Artisan tail 实时显示系统日志 安装 composer require spatie/laravel-tail 执行完即可,常用命令 php artisan help tail php artisan tail 更详细的说明请参考:https://git...

yii debug和gii模块

php

开启 vi config/main.php if (YII_ENV_DEV) { $config['bootstrap'][] = 'debug'; $config['modules']['debug'] = [ 'class'=>'yii\debug\Module', 'allowedIPs'=>['*',], ]; $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = [ 'class' => 'yii\gii\Module', ...

The file or directory to be published does not exist: /var/www/yii-demo/vendor/yiisoft/yii2/gii/assets

php

报错内容 Invalid Argument – yii\base\InvalidArgumentException The file or directory to be published does not exist: /var/www/yii-demo/vendor/yiisoft/yii2/gii/assets 这错报的莫名其秒 我的目录结构 ├── api │   ├── config │   │   ├── bootstrap.php │   │   ├── main.php │   │   └── params.php │   ├── controllers │   │   ...

Json Web Token(JWT)的使用

php

JWT 用于生成token,token里面可以包含用户信息,下面介绍两种php的实现方法 借助 composer 库 composer require firebase/php-jwt 生成token <?php require_once __DIR__ . '/../vendor/autoload.php'; use Firebase\JWT\JWT; $key = 'abc';//app key $payload = [ 'iss' => 'http://example.org', 'aud' => 'http://example.com', 'iat' => ...

Redis 应用场景

php

首先,总结一下这些应用场景,它们不是独立存在的,很多都还是要依赖mysql;甚至项目初期这些都不是第一选择,很多场景mysql也能做,并且更简单 生成唯一的随机数 很多网站的详情页链接都有一个随机数,比如http://www.cuiwei.net/p/1937090613、https://www.zhihu.com/question/48759965、https://segmentfault.com/a/1190000041091095等 通常的做法是:一个code(id,article_id,code,used_time)表,一个article(id,code, ...)表,在添加文章时从c...

php使用yield解决Fatal error: Allowed memory size of 134217728 bytes exhausted

php

yield生成器允许你 在 foreach 代码块中写代码来迭代一组数据而不需要在内存中创建一个数组。 错误还原 <?php $file = './access.log'; $lines=readfile2($file); foreach($lines as $line){ file_put_contents('access2.log', $line.PHP_EOL, FILE_APPEND); } echo 'ok'.PHP_EOL; //试图读取一个248M的日志文件,将所有行放到一个数组里面并返回 function readFile2($path){ $handle ...

Google play 实时开发者通知——一次性购买

php

若使用通知需要先配置,详见:http://www.cuiwei.net/p/1632593347/ 实时开发者通知 有三种类型 订阅购买 - SubscriptionNotification 一次性购买 - OneTimeProductNotification play管理中心发出的测试消息 - TestNotification 这篇文章只说 TestNotification和OneTimeProductNotification两种 TestNotification 这个没什么好说的,就是你配置完实时开发者通知,在play管理中心发出的测试通知 OneTimeProductNotific...

使用服务账号请求Google Play Developer API

php

Google Play 虽然提供了纯客户端的对接方案,但是官方也更推荐将敏感逻辑移至后端 Google Play Developer API 是一种服务器到服务器 API,与 Android 平台上的 Google Play 结算库相辅相成。此 API 提供了 Google Play 结算库中未提供的功能,如安全地验证购买交易以及为用户办理退款。 配置 Google Play Developer API 若要使用 Google Play Developer API,您需有一个 Google Cloud 项目。 关联Google Cloud项目 如上图,你可以选择关联现有项目,也可以选择创建新...