PHP
Webben
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Mac Nginx Mysql 常用操作命令及位置
Nginx# 查看安装配置nginx -V# 启动brew services start nginx# 停止brew services stop nginx# 重启brew services restart nginx# nginx 配置/usr/local/Cellar/nginx/conf//usr/local/etc/vi /usr/local/etc/nginx/nginx.conftailf /usr/local/var/log/nginx/error.lo原创 2021-08-26 20:12:33 · 253 阅读 · 0 评论 -
ArrayAccess(数组式访问对象)
InterfaceCountable 计数/** * 计数 * 类实现 Countable 可被用于 count() 函数. * @man https://www.php.net/manual/zh/class.countable.php **/interface Countable { /* 方法 */ abstract public count():int}Iterator 迭代器/** * 迭代器 * 可在内部迭代自己的外部迭代器或类的接口。 * @man htt原创 2021-05-19 15:28:01 · 479 阅读 · 0 评论 -
Visual Studio Code 报错 Undefined type .intelephense(1009)
VSCode 配置可以把相关类库目录及 vendor 目录添加进来设置>Intelephense>Exvironment:Include Paths>添加依赖目录获取所有参数$class_list = get_declared_classes();foreach( $class_list as $class_name){ if( substr( $class_name, 0, 3) != 'Ap_'){ continue; } echo "原创 2021-03-05 19:33:23 · 5835 阅读 · 0 评论 -
PHP shmop_open shmop内存共享 进程更改监听 命令执行输入 IPC 进程通讯
PHP shmop_open shmop内存共享+*简单的例子假如 A 进程在等在B是否有更新 ,有更新的话 A 进程再进行执行比如现在有个天气预报的设备, 如果天气差异大的话就进行数据更新, 此时可以把数据放到 IPC中, 然后 PHP 监听 进程内容改变, 如果改变了 就进行数据库入库,再用监听者模式 告诉底下的API,天气预报更新了 然后API端会来到你这里获取新的天气情况shmop主要函数 具体操作shmop_open (创建或打开共享内存块)、shmop_write (向共享内存块中写入转载 2020-11-27 15:37:58 · 316 阅读 · 0 评论 -
自定义 Laravel (monolog)日志位置,并增加请求ID
修改 bootstrap/app.php 文件$app->configureMonologUsing(function($monolog) use ($app) { $monolog->pushHandler( (new Monolog\Handler\RotatingFileHandler( '/var/logs/app/lar...原创 2017-12-18 16:24:28 · 4109 阅读 · 1 评论 -
将项目中执行的 SQL 打印到 laravel.log 文件中
AppServiceProvideruse DB;use Log;public function boot() { // 第一种方式(推荐) DB::listen(function ($query) { Log::info( '执行 SQL:' . vsprintf(str_replace('?', '"%s"', $query->sql)原创 2017-11-15 16:36:27 · 752 阅读 · 0 评论 -
Laravel常用扩展包
DebugbarLaravel Debugbar 是一个让你在开发期间可以便捷查看应用所有信息的扩展包,以方便调试。Github:https://github.com/barryvdh/laravel-debugbar Composer:https://packagist.org/packages/barryvdh/laravel-debugbarIDE Helper该扩展包生成一个 IDE 可以原创 2017-07-31 15:00:03 · 1392 阅读 · 0 评论 -
laravel框架支路由规则MVC配置
Route::any('/{module}/{class}/{action}', function($module, $class, $action) { $ctrl = \App::make("\\App\\Http\\Controllers\\" . $module . "\\" . $class . "Controller"); return \App::call([$ctrl原创 2017-07-17 10:53:37 · 392 阅读 · 0 评论 -
php 安装 7.1.* 过程及问题
下载https://www.php.net/downloads.php如果Chain慢的话,可以选择其他渠道。配置#查看安装命令php -i | grep configure#Configure Command => './configure' '--prefix=/home/work/odp/php7' '--with-curl' '--with-freetype-dir...原创 2019-03-25 15:06:07 · 391 阅读 · 0 评论 -
PHP利用多进程处理任务
PHP多进程一般应用在PHP_CLI命令行中执行php脚本,不要在web访问时使用。多进程处理分解任务一般要比单进程更快。php 查看是否安装多进程模块:php -m | grep pcntl( pcntl是 process control 的缩写)创建子进程的函数 fork ,了解过C语言的同学应该都知道这个。php多进程的一些库函数手册:http://php.net/manual...原创 2019-05-29 17:11:25 · 445 阅读 · 0 评论 -
抓取脚本
<?php$url = 'xxxxxxxxxxxxxxxxxxxx';$file = 'index.html';set_time_limit(0);define('ROOT' , dirname(__FILE__).'/' );$robot = new Spider(array( 'site' => $url, 'queue' => array( $...原创 2019-06-13 14:10:25 · 888 阅读 · 0 评论 -
PHP根据姓名分析男女性别(Python转PHP)
PHP根据姓名分析男女性别参考:https://github.com/observerss/ngender$name = $argv[1];$gender = new Gender();$ret = $gender->guess( $name);echo $name."\t".$ret[0]."\t".$ret[1];class Gender{ /** *...原创 2019-06-22 18:29:51 · 2254 阅读 · 0 评论 -
一千行MySQL学习笔记
一千行MySQL学习笔记转自:https://www.cnblogs.com/shockerli/p/1000-plus-line-mysql-notes.html/* 启动MySQL */net start mysql/* 连接与断开服务器 */mysql -h 地址 -P 端口 -u 用户名 -p 密码/* 跳过权限验证登录MySQL */mysqld --skip-gran...转载 2019-07-05 13:39:04 · 291 阅读 · 0 评论 -
Laravel 5.4 逻辑异常处理
Laravel 5.4 逻辑异常处理修改 app\Exceptions\Handler.php public function render($request, Exception $exception){ if ($exception instanceof ValidationException) { return $this->invalidJson($原创 2017-12-28 14:30:17 · 2307 阅读 · 0 评论 -
用 composer 造轮子
composer 是 PHP 的依赖管理工具,本篇文章就来说明如何构建一个包,并提交到 Packagist ,这样别人就可以方便地通过 composer 使用你的包了。开发 composer 包有以下几个步骤:初始化 composer.json 文件定义命名空间及包名实现包需要实现的功能提交到 GitHub在 Packagist 注册包初始化 composer.json 文件安装好 c转载 2017-09-06 17:56:56 · 507 阅读 · 0 评论 -
Laravel 及 composer 安装及使用
安装composerphp -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"php -r "if (hash_file('SHA384', 'composer-setup.php') === '669656bab3166a7aff8a7506b8cb2d1c292f042046c5a994c43155c0be原创 2017-07-12 15:58:14 · 2225 阅读 · 0 评论 -
guzzle/guzzle 日常使用
GuzzleGuzzle 是一个 PHP HTTP 客户端,致力于让发送 HTTP 请求以及与 Web 服务进行交互变得简单。 Github:https://github.com/guzzle/guzzle Composer:https://packagist.org/packages/guzzlehttp/guzzle发送请求use GuzzleHttp\Client;$client =原创 2017-08-30 18:27:02 · 5438 阅读 · 0 评论 -
laravel Route 用法
Route::group([ 'prefix' => 'admin', ], function() { Route::get('/', 'AdminController@welcome'); Route::get('/manage', [ 'middleware' => ['permission:manage-admins'], 'uses原创 2017-08-31 10:53:41 · 4205 阅读 · 0 评论 -
Nginx 和 Apache 为PHP增加环境变量
Nginx:location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_buffer_size 128k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 256k; fastcgi_param SCRIPT_FILENAME $document_ro原创 2017-10-18 17:17:37 · 719 阅读 · 0 评论 -
PHP 调用Java Dubbo服务(Dubbo、Hessian、JsonRPC)
PHP 调用Java Dubbo服务(Dubbo、Hessian、JsonRPC)原创 2017-10-27 10:49:44 · 9248 阅读 · 1 评论 -
PHP使用SnowFlake算法生成唯一ID
namespace App\Services;abstract class Particle { const EPOCH = 1479533469598; const max12bit = 4095; const max41bit = 1099511627775; static $machineId = null; public static function原创 2017-03-15 18:10:59 · 3674 阅读 · 2 评论 -
Composer 常用包
HTTP请求库(guzzlehttp/guzzle)composer require hashids/hashids数字ID转字符串(hashids/hashids)composer require hashids/hashids图片处理 intervention/imagecomposer require intervention/image邮件发送 (phpmailer/phpmailer)co原创 2017-07-31 17:06:51 · 2290 阅读 · 0 评论 -
php soap 通信
与 xx crm 通讯接口调用$url = 'http://xxxxx.com/xxxxxxxxxxxxx?WSDL';$soapClient = new SoapClient( $url , array('trace'=>true) ); // Prepare SoapHeader parameters $sh_header = array( 'UserIdenti...原创 2018-07-16 17:28:30 · 510 阅读 · 0 评论 -
stream_context_create 和 file_get_contents POST 使用方法
参考stream_context_create 函数说明上下文(Context)选项和参数HTTP context 选项 代码$opts = array( 'http' => array( 'method' => "POST", 'header' => array( "Accept-lang...原创 2018-08-28 16:19:08 · 1458 阅读 · 0 评论 -
header fields 详解
参考List of HTTP header fields翻译标准要求字段 字段名 说明 例子 状态 A-IM 可接受实例操作的请求 A-IM: feed 永久的 Accept 对于响应来说是(/是)可接受的媒体类型。看到内容协商。 Accept: text/html 永久的 Accept-Charset 可接...原创 2018-08-28 16:52:23 · 3540 阅读 · 0 评论 -
Nginx + PHP 502 超时,靠!!
nginx+php 出现502 bad gateway,一般这都不是nginx的问题,而是由于 fastcgi或者php的问题导致的,常见的有以下几种。php.ini 的memory_limit 过小(如果有个别php程序进程需要占用极大内存时这个必须注意)php-fpm.conf 中max_children或者max_requests 设置不合理(设置过小会因为没有足够的cgi进程...原创 2018-10-18 18:23:12 · 5228 阅读 · 0 评论 -
服务器架构图
服务器架构图:原创 2018-04-08 11:14:17 · 4473 阅读 · 0 评论 -
Laravel 5.4 私有包搭建工厂模式
本地下载:laravel 私有包(工厂模式demo)1、把包放到laravel项目下 vendor/webben/wauth/src; 2、修改根目录下的 composer.json,找到 autoload 相关代码块:"autoload": { "classmap": [ "database" ], "psr-4": { "App\\":原创 2017-10-19 16:53:53 · 488 阅读 · 0 评论 -
PHP imagick安装与配置
PHP imagick安装与配置原创 2017-03-20 14:40:41 · 2211 阅读 · 0 评论
分享