php
请叫我、诚哥
这个作者很懒,什么都没留下…
展开
-
laravel Redis 锁机制代码
<?phpnamespace App\Service;use Illuminate\Support\Facades\Redis;class RedisLockService{ public static function lock($key, $expire = 10) { if(!$key) { return false; } do { if($acquired = (原创 2021-06-23 14:51:53 · 399 阅读 · 1 评论 -
Laravel Redis的使用
laravel中使用redis首先需要你通过 Composer 安装 predis/predis 包:composer require predis/predis配置: redis的配置文件是:config/database.php 'redis' => [ 'client' => 'predis', 'default' => [ 'host' => env('REDIS_HOST', '127.转载 2021-06-22 15:06:27 · 584 阅读 · 0 评论 -
laravel队列常驻运行问题 queue:
方法:1根据官方文档使用–daemon可让队列常驻运行。对应命令行执行php artisan queue:work --daemon;但是当前命令还是会因为使用Ctrl+C。将进程给关闭。如何常驻在后台执行?官方文档还让你安装 supervisor 你为什么不安装呢?用 supervisor 可以常驻后台,并且监控 php artisan queue:work --daemon 的运行这样即使重启,都可以稳定的运行队列。安装教程:https://www.load-page.com/bas…方法原创 2021-05-08 11:28:08 · 1302 阅读 · 0 评论 -
laravel php artisan migrate 报错 什么key太长
# 查看数据库被限制了索引的大小SHOW variables like 'innodb_large_prefix'# 解除限制SET GLOBAL INNODB_LARGE_PREFIX = ON;# 查看当前的innodb_file_format引擎格式类型SHOW variables like 'innodb_file_format'# 修改SET GLOBAL innodb_file_format = BARRACUDA;...原创 2021-04-28 14:00:01 · 98 阅读 · 0 评论 -
laravel 框架源码
if (method_exists($this, 'map')) { $this->app->call([$this, 'map']); }原创 2021-04-22 15:32:44 · 129 阅读 · 0 评论 -
php call 静态
class Test{ public function __call($name, $arguments) { // TODO: Implement __call() method. var_dump($name); var_dump($arguments); } public static function __callStatic($name, $arguments) { var_dump($na原创 2021-04-19 09:07:12 · 125 阅读 · 0 评论 -
laravel 排序
$arr = [ ['sort' => '2020-11-9'], ['sort' => '2020-11-10'], ['sort' => '2020-11-11']];$r = collect($arr)->sortByDesc(function ($value) { return strtotime($value['sort']);})->values()->all();dd($r);原创 2021-04-15 08:42:12 · 888 阅读 · 0 评论 -
php-fpm用配置文件开启多个进程
创建第二个php-fpm进程所使用的主配置文件复制主配置文件 cp /etc/php-fpm.conf /etc/php-fpm2.conf2)复制子配置文件 cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www2.conf (注意子配置文件名会跟我这里有所不同注意www.conf是否存在,用存在的作为复制对象)3)更改子配置文件 www2.conf的配置listen = 127.0.0.1:9001 – 更改www2.conf 的监听端口4)更改主配置文件p原创 2021-04-09 10:53:41 · 398 阅读 · 0 评论 -
linux 如果gd库安装不上
如果gd库安装不上yum install php-gd --enablerepo=remi,remi-php55原创 2021-04-09 10:30:03 · 222 阅读 · 0 评论 -
php加密解密
class Aes { //密钥 须是16位 public $key ; /** * 解密字符串 * @param string $data 字符串 * @return string */ public function __construct() { $this->key = '1234567890123456'; } public function decode($str) { return openssl_decrypt(base64_decode($str),"AES-128-ECB",$th原创 2021-03-31 15:51:19 · 82 阅读 · 0 评论 -
laravel 分页转集合
分页转集合paginate($this->page_size);$r = r−>getCollection()−>transform(function(r->getCollection()->transform(function (r−>getCollection()−>transform(function(model) { });原创 2021-01-28 10:38:07 · 125 阅读 · 0 评论 -
laravel 编辑模式
php artisan tinkerlaravel 编辑模式原创 2021-01-03 18:55:47 · 153 阅读 · 0 评论 -
laravel引入libs
在composer.json中的autoload下的classmap下加入"app/Libs/Dingding"然后在命令行中运行composer dump-autoload1、首先去composer.json文件,去掉你引入的文件路径,如“autoload” : {“classmap” : [“database”,“app/Libs/Dingding” //假设上面我们引进去了这个文件夹下文件],“psr-4” : {“App\” : “app/”}},2、现在去原创 2021-01-03 16:06:55 · 369 阅读 · 0 评论 -
laravel沒有代碼提示解決
虽然安装了插件,但模型还是没有代码提示,可以通过安装插件解决; composer require barryvdh/laravel-ide-helper php artisan ide-helper:generate – 为 Facades 生成注释 php artisan ide-helper:models – 为数据模型生成注释 php artisan ide-helper:meta – 生成 PhpStorm Meta file...原创 2020-12-30 08:42:59 · 348 阅读 · 0 评论