标签 PHP 中的文章

PHP项目容器化改造

随着项目的更新迭代,项目复杂度越来越高,项目已从单一的 PHP 开发演变成 多语言 多运行时 的大型项目,进而更新部署也变得繁琐,所有需要一个 统一 自动化 的更新部署方案。至此 Docker容器化 部署则成为一个好的选择,一、方便各种私有化部署,二、也可以根据各模块压力灵活调整配置。 Dockerfile 简单示例 经过选型……

阅读全文

一个简单的docker composer shell

Docker-Composer Use step1. install docker View https://docs.docker.com/install/ step2. pull composer image docker pull composer step3. copy composer.sh to /usr/bin/composer sudo cp composer.sh /usr/bin/composer Success enjoy it.……

阅读全文

阿里云 腾讯云 华为云 composer 镜像

镜像地址: 阿里云: https://mirrors.aliyun.com/composer/ 腾讯云: https://mirrors.cloud.tencent.com/composer/ 华为云: https://mirrors.huaweicloud.com/repository/php/ 其他的: laravel-china:http://packagist.laravel-china.org/ (相对稳定,更新频率有点慢) cnpkg: https://php.cnpkg.org/ (速度不太稳定,更新频率比较快) phpcomposer: https://pkg.phpcomposer.com/ (凉了有段时间了)……

阅读全文

laravel5 join updated_at 冲突 列错误

使用->toBase()方法可解决,这个问题将在5.8版本中修复 Comment::where([ 'author_id' => $customer_id, 'scenes' => 'article' ]) ->join('xb_article', function ($join) { $join->on('xb_comment.scenes_id', '=', 'xb_article.id') ->whereNotNull('xb_article.deleted_at'); }) ->toBase() ->delete(); 参考链接:https://github.com/laravel/framework/issues/13909……

阅读全文

EasyWechat开发微信支付/小程序支付/H5支付/App支付代码实例

代码实例: $tradeType = "支付场景,APP/JSAPI"; $accountPayment = [ 'APP' => [ 'app_id' => 'app_id', 'mch_id' => 'mch_id', 'key' => 'XXXXXXXXXXXXXXXXXXXXXXX', 'cert_path' => app_path('resources/cert/apiclient_cert.pem'), 'key_path' => app_path('resources/cert/apiclient_key.pem'), 'notify_url' => route('weChatNotifyUrl'), ], 'JSAPI' => [ 'app_id' => 'app_id', 'mch_id' => 'mch_id', 'key' => 'XXXXXXXXXXXXXXXXXXXXXXX', 'cert_path' => app_path('resources/cert2/apiclient_cert.pem'), 'key_path' => app_path('resources/cert2/apiclient_key.pem'), 'notify_url' => route('weChatNotifyUrl'), ], ]; $app = Factory::payment($accountPayment[$tradeType]); $order_info = [ 'body' => $title, 'out_trade_no' => $order_number, 'total_fee' => $amount, 'trade_type' => $tradeType, // 交易类型 JSAPI | NATIVE |APP | WAP ]; $result = $app->order->unify($order_info); if ($tradeType == 'JSAPI') { // 微信内H5/小程序支付 $jssdk = $app->jssdk; $config = $jssdk->bridgeConfig($result['prepay_id'], false); } else {……

阅读全文

php7高效生成二维码:composer和荷兰PHP开发者的QrCode

QR Code By endroid This library helps you generate QR codes in a jiffy. Makes use of bacon/bacon-qr-code to generate the matrix and khanamiryan/qrcode-detector-decoder for validating generated QR codes. Further extended with Twig extensions, generation routes, a factory and a Symfony bundle for easy installation and configuration. Installation Use Composer to install the library. $ composer require endroid/qr-code Basic usage use Endroid\QrCode\QrCode; $qrCode = new QrCode('Life is too short to be generating QR codes'); header('Content-Type: '.$qrCode->getContentType()); echo $qrCode->writeString(); Advanced usage use Endroid\QrCode\ErrorCorrectionLevel; use Endroid\QrCode\LabelAlignment; use Endroid\QrCode\QrCode; use Endroid\QrCode\Response\QrCodeResponse; // Create a basic QR code $qrCode = new QrCode('Life is too short to be generating QR codes'); $qrCode->setSize(300); // Set advanced options $qrCode->setWriterByName('png'); $qrCode->setMargin(10); $qrCode->setEncoding('UTF-8'); $qrCode->setErrorCorrectionLevel(ErrorCorrectionLevel::HIGH); $qrCode->setForegroundColor(['r' => 0, 'g' => 0, 'b' => 0, 'a' => 0]); $qrCode->setBackgroundColor(['r' => 255, 'g' => 255, 'b' => 255, 'a' => 0]); $qrCode->setLabel('Scan……

阅读全文

phpoffice/phpspreadsheet生成excel,浏览器下载excel表格方法

composer 安装 phpoffice/phpspreadsheet // 引入 namespace use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; // 创建 $spreadsheet = new Spreadsheet(); $sheet = $spreadsheet->getActiveSheet(); // 设置文件名 $fileName = 'cnbattle.xlsx'; // 设置表格数据,当前为循环设置 1000行,25列的数据 $hang = 1000; $lei = 26; for ($x = 0; $x < $lei; $x++) { if ($lei>26){ die('$lei不能大于26'); } $leiStr = chr(65 + $x); for ($i = 1; $i <= $hang; $i++) { $sheet->setCellValue($leiStr . $i, 'value-' . $leiStr . $i); } } //告诉浏览器输出07Exc……

阅读全文

PHP Fatal Error: Constant expression contains invalid operations

属性声明是由关键字 public,protected 或者 private 开头,然后跟一个普通的变量声明来组成。属性中的变量可以初始化,但是初始化的值必须是常数,这里的常数是指 PHP 脚本在编译阶段时就可以得到其值,而不依赖于运行时的信息才能求值。 class Controller { private $Domain = 'https://www.cnbattle.com'; // private $Url = $this->Domain.'/index.php'; 这样是错误的 private $Url; public function __construct(){ $this->Url = $this->Domain.'/index.php'; } }……

阅读全文

最近文章

分类

标签

友情链接

其它