This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php declare(strict_types=1); | |
| use GuzzleHttp\Client; | |
| use Swoft\Stdlib\Helper\ArrayHelper; | |
| use GuzzleHttp\Exception\RequestException; | |
| /** | |
| * 数据格式化 | |
| * | |
| * @access public |
This gist assumes:
- you have a local git repo
- with an online remote repository (github / bitbucket etc)
- and a cloud server (Rackspace cloud / Amazon EC2 etc)
- your (PHP) scripts are served from /var/www/html/
- your webpages are executed by apache
- apache's home directory is /var/www/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Illuminate\Support\Facades\Validator; | |
| class ImageHelper | |
| { | |
| // 自定义验证函数 | |
| protected $validator; | |
| // 上传图片字段 | |
| protected $field = 'image'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| BUCKETNAME="your_s3_bucket" | |
| LOGDIR="/var/log/nginx" | |
| LOGDATE=$(date +"%Y%m%d") | |
| HOST=$(wget -q -O- http://169.254.169.254/latest/meta-data/instance-id) | |
| LOGFILES=("access") | |
| echo "Moving access logs to dated logs.." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //动态修改env文件 | |
| $path = base_path('.env'); | |
| if (file_exists($path)) { | |
| //Try to read the current content of .env | |
| $current = file_get_contents($path); | |
| //Store the key | |
| $original = []; | |
| if (preg_match('/^XCHACHA_KEY=(.+)$/m', $current, $original)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Formater | |
| { | |
| public static function bytesToHuman($bytes) | |
| { | |
| $units = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; | |
| for ($i = 0; $bytes > 1024; $i++) { | |
| $bytes /= 1024; | |
| } |