成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

那些 PHP 開發(fā)者可能用得上的工具

JowayYoung / 2181人閱讀

PHP 函數(shù)的 JavaScript 實(shí)現(xiàn)
module.exports = function array_sum (array) { // eslint-disable-line camelcase
  //  discuss at: http://locutus.io/php/array_sum/
  // original by: Kevin van Zonneveld (http://kvz.io)
  // bugfixed by: Nate
  // bugfixed by: Gilbert
  // improved by: David Pilia (http://www.beteck.it/)
  // improved by: Brett Zamir (http://brett-zamir.me)
  //   example 1: array_sum([4, 9, 182.6])
  //   returns 1: 195.6
  //   example 2: var $total = []
  //   example 2: var $index = 0.1
  //   example 2: for (var $y = 0; $y < 12; $y++){ $total[$y] = $y + $index }
  //   example 2: array_sum($total)
  //   returns 2: 67.2
  var key
  var sum = 0
  // input sanitation
  if (typeof array !== "object") {
    return null
  }
  for (key in array) {
    if (!isNaN(parseFloat(array[key]))) {
      sum += parseFloat(array[key])
    }
  }
  return sum
}
Underscore.js 的 PHP 版
function __($item=null) {
  $__ = new __;
  if(func_num_args() > 0) $__->_wrapped = $item;
  return $__;
}
自動(dòng)生成 gitignore 文件
https://www.gitignore.io/api/laravel
# Created by https://www.gitignore.io/api/laravel

### Laravel ###
vendor/
node_modules/
npm-debug.log

# Laravel 4 specific
bootstrap/compiled.php
app/storage/

# Laravel 5 & Lumen specific
public/storage
public/hot
storage/*.key
.env.*.php
.env.php
.env
Homestead.yaml
Homestead.json

# Rocketeer PHP task runner and deployment package. https://github.com/rocketeers/rocketeer
.rocketeer/

# End of https://www.gitignore.io/api/laravel
爬蟲組件
composer global require slince/spider *@dev
use SlinceSpiderSpider;

$spider = new Spider();
$spider->run("http://www.baidu.com");
簡單、 靈活、強(qiáng)大的 PHP 采集工具
use QLQueryList;
//采集某頁面所有的圖片
$data = QueryList::Query("http://cms.querylist.cc/bizhi/453.html",array(
    //采集規(guī)則庫
    //"規(guī)則名" => array("jQuery選擇器","要采集的屬性"),
    "image" => array("img","src")
    ))->data;
//打印結(jié)果
print_r($data);

//采集某頁面所有的超鏈接
//可以先手動(dòng)獲取要采集的頁面源碼
$html = file_get_contents("http://cms.querylist.cc/google/list_1.html");
//然后可以把頁面源碼或者HTML片段傳給QueryList
$data = QueryList::Query($html,array(
    "link" => array("a","href")
    ))->data;
//打印結(jié)果
print_r($data);
在線測試采集并查看采集結(jié)果 http://querylist.cc/page-Querytest.html
在線測試代碼

$array=[
    ["name"=>"張三","age"=>"23"],
    ["name"=>"李四","age"=>"64"],
    ["name"=>"王五","age"=>"55"],
    ["name"=>"趙六","age"=>"66"],
    ["name"=>"孫七","age"=>"17"],
];
$sort = array(
    "direction" => "SORT_ASC", //排序順序標(biāo)志 SORT_DESC 降序;SORT_ASC 升序
    "field"     => "age",       //排序字段
);
$arrSort = array();
foreach($array as $uniqid => $row){
    foreach($row AS $key=>$value){
        $arrSort[$key][$uniqid] = $value;
    }
}
array_multisort($arrSort[$sort["field"]], constant($sort["direction"]), $array);
print_r($array);
中文轉(zhuǎn)拼音工具
//https://hellogithub.com/category/PHP%20%E9%A1%B9%E7%9B%AE/
use OvertruePinyinPinyin;
$pinyin = new Pinyin();
$pinyin->convert("帶著希望去旅行,比到達(dá)終點(diǎn)更美好");
// ["dai", "zhe", "xi", "wang", "qu", "lv", "xing", "bi", "dao", "da", "zhong", "dian", "geng", "mei", "hao"]

$pinyin->convert("帶著希望去旅行,比到達(dá)終點(diǎn)更美好", PINYIN_UNICODE);
// ["dài","zhe","xī","wàng","qù","lǚ","xíng","bǐ","dào","dá","zhōng","diǎn","gèng","měi","hǎo"]

$pinyin->convert("帶著希望去旅行,比到達(dá)終點(diǎn)更美好", PINYIN_ASCII);
//["dai4","zhe","xi1","wang4","qu4","lv3","xing2","bi3","dao4","da2","zhong1","dian3","geng4","mei3","hao3"]
美化 curl
$ git clone https://github.com/talhasch/php-httpstat
$ cd php-httpstat
$ cp httpstat.php /usr/local/bin/httpstat
$ chmod +x /usr/local/bin/httpstat
$ httpstat http://www.google.com
在線正則表達(dá)式測試

在線測試 redis

在線練習(xí) git

檢測 PHP 應(yīng)用的代碼復(fù)雜度
composer global require "phploc/phploc=*"
$ phploc src
phploc 4.0.0 by Sebastian Bergmann.

Directories                                          3
Files                                               10

Size
  Lines of Code (LOC)                             1882
  Comment Lines of Code (CLOC)                     255 (13.55%)
  Non-Comment Lines of Code (NCLOC)               1627 (86.45%)
  Logical Lines of Code (LLOC)                     377 (20.03%)
    Classes                                        351 (93.10%)
      Average Class Length                          35
        Minimum Class Length                         0
        Maximum Class Length                       172
      Average Method Length                          2
        Minimum Method Length                        1
        Maximum Method Length                      117
    Functions                                        0 (0.00%)
      Average Function Length                        0
    Not in classes or functions                     26 (6.90%)
php http 請求工具
$response = Zttp::withHeaders(["Fancy" => "Pants"])->post($url, [
    "foo" => "bar",
    "baz" => "qux",
]);

$response->json();
// => [
//  "whatever" => "was returned",
// ];
任務(wù)管理
composer global require consolidation/robo
class RoboFile {
/**
 * Each public method is a command in runner
 * parameters are arguments in console
 *
 * use "./robo test" to run tests on a project
 */
function test($pathToSelenium = "~/selenium.jar")
{
    // starts PHP server in background
    $this->taskPhpServer(8000)
        ->background()
        ->dir("web")
        ->run();

    // launches Selenium server
    $this->taskExec("java -jar ".$pathToSelenium)
        ->background()
        ->run();

    // runs PHPUnit tests
    $this->taskPHPUnit()
        ->run();
}
phpstorm 技巧

php ai
composer require php-ai/php-ml
require_once "vendor/autoload.php";

use PhpmlClassificationKNearestNeighbors;

$samples = [[1, 3], [1, 4], [2, 4], [3, 1], [4, 1], [4, 2]];
$labels = ["a", "a", "a", "b", "b", "b"];

$classifier = new KNearestNeighbors();
$classifier->train($samples, $labels);

echo $classifier->predict([3, 2]);
// return "b"
PHP driver for FFMpeg
$ffmpeg = FFMpegFFMpeg::create();
$video = $ffmpeg->open("video.mpg");
$video
    ->filters()
    ->resize(new FFMpegCoordinateDimension(320, 240))
    ->synchronize();
$video
    ->frame(FFMpegCoordinateTimeCode::fromSeconds(10))
    ->save("frame.jpg");
$video
    ->save(new FFMpegFormatVideoX264(), "export-x264.mp4")
    ->save(new FFMpegFormatVideoWMV(), "export-wmv.wmv")
    ->save(new FFMpegFormatVideoWebM(), "export-webm.webm");
編碼格式化工具
//http://cs.sensiolabs.org/  composer  global require fabpot/php-cs-fixer
//wget http://get.sensiolabs.org/php-cs-fixer.phar -O php-cs-fixer
curl http://get.sensiolabs.org/php-cs-fixer.phar -o php-cs-fixer
sudo chmod a+x php-cs-fixer
sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
# 格式化目錄 如果是當(dāng)前目錄的話可以省略目錄
php-cs-fixer fix /path/to/dir
# 格式化文件
php-cs-fixer.phar fix /path/to/file
//cat foo.php | php-cs-fixer fix --diff -
#https://housanpai.com/articles/10
php medoo
composer require catfan/Medoo
// 如果你通過 composer 安裝, 只需在項(xiàng)目的開始部分加上此代碼即可自動(dòng)加載。
require "vendor/autoload.php";
 
// 或者你是下載 medoo.php 并放置到項(xiàng)目目錄中,require 即可。
require  "medoo.php";
 
$database = new medoo([
    // 必須的
    "database_type" => "mysql",
    "database_name" => "name",
    "server" => "localhost",
    "username" => "your_username",
    "password" => "your_password",
    "charset" => "utf8",
 
    // [可選]
    "port" => 3306,
 
    // [可選] 表名前綴
    "prefix" => "PREFIX_",
 
    // [可選] 連接的驅(qū)動(dòng)選項(xiàng),請閱讀 http://www.php.net/manual/en/pdo.setattribute.php
    "option" => [
        PDO::ATTR_CASE => PDO::CASE_NATURAL
    ]
]);
 
$database->insert("account", [
    "user_name" => "foo",
    "email" => "[email protected]"
]);
在線文檔分享工具

composer create-project showdoc/showdoc

php的ngrok客戶端 比對兩個(gè)數(shù)據(jù)庫的表結(jié)構(gòu),并自動(dòng)修正
git clone https://github.com/exinnet/mysqldiff.git
cd mysqldiff
vi config.php # config mysql connection info

php mysqldiff.php
cron

file_get_contents("https://hchk.io/e9ad1415-566c-40c9-9c97-a298d727ab68");

語法檢測
composer require overtrue/phplint -vvv
use OvertruePHPLintLinter;

$path = __DIR__ ."/app";
$exclude = ["vendor"];
$extensions = ["php"];

$linter = new Linter($path, $exclude, $extensions);

// get errors
$errors = $linter->lint();

//
// [
//    "/path/to/foo.php" => [
//          "error" => "unexpected "$key" (T_VARIABLE)",
//          "line" => 168,
//          "file" => "/path/to/foo.php",
//      ],
//    "/path/to/bar.php" => [
//          "error" => "unexpected "class" (T_CLASS), expecting "," or ";"",
//          "line" => 28,
//          "file" => "/path/to/bar.php",
//      ],
// ]
生成Material Design風(fēng)格頭像
// composer 
require(__DIR__ . "/vendor/autoload.php");
use MdMDAvatars;

$Avatar = new MDAvatars("X", 512);
$Avatar->Output2Browser();
$Avatar->Save("./avatars/Avatar256.png", 256);
使用screw plus來保護(hù)php代碼安全 一個(gè)最精簡的php多進(jìn)程控制庫
$sf = new SimpleFork(2, "my-process"); // 2代表子進(jìn)程數(shù), "my-process"是進(jìn)程的名字

$sf->master(function ($sf) {
    // 主進(jìn)程的方法請包裹在master里
    while ($sf->loop(100)) { // 100為等待的毫秒數(shù)
        $sf->submit("http://www.google.cn/", function ($data) { // 使用submit方法將其提交到一個(gè)空閑的進(jìn)程,如果沒有空閑的,系統(tǒng)會(huì)自動(dòng)等待
            echo $data;
        });
    }
})->slave(function ($url, $sf) {
    $sf->log("fetch %s", $url); // 使用內(nèi)置的log方法,子進(jìn)程的log也會(huì)被打印到主進(jìn)程里
    return http_request($url);  // 直接返回?cái)?shù)據(jù),主進(jìn)程將在回調(diào)中收到
});
A PHP MySQL PDO class similar to the the Python MySQLdb
$DB->query("SELECT * FROM fruit WHERE name=".$_GET["name"]);

$DB->query("SELECT * FROM fruit WHERE name=? and color=?",array("apple","red"));
$DB->query("SELECT * FROM fruit WHERE name=:name and color=:color",array("name"=>"apple","color"=>"red"));
$DB->query("SELECT * FROM fruit WHERE name IN (?)",array("apple","banana"));
圖片處理
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_URL, "https://avatars0.githubusercontent.com/u/5785188?v=3&s=460");
$response =  curl_exec($ch);
curl_close($ch);

$UploadAvatar = new ImageResize("String", $response);
$Result = $UploadAvatar->Resize(256, "upload/avatar/large.png", 80);
Linux 圖形化性能監(jiān)視器 編寫PHP代碼片段終極機(jī)器人

PHP 代碼轉(zhuǎn) Python
def substr (self, s, start, length = None):
        """Returns the portion of string specified by the start and length 
        parameters.
        """
       if len(s) >= start:
            if start > 0:
                return False
            else:
                return s[start:]
        if not length:
            return s[start:]
        elif length > 0:
            return s[start:start + length]
        else:
            return s[start:length]
php部署工具
curl -LO https://deployer.org/deployer.phar
mv deployer.phar /usr/local/bin/dep
chmod +x /usr/local/bin/dep
composer require deployer/deployer

公眾號:蘇生不惑

文章版權(quán)歸作者所有,未經(jīng)允許請勿轉(zhuǎn)載,若此文章存在違規(guī)行為,您可以聯(lián)系管理員刪除。

轉(zhuǎn)載請注明本文地址:http://systransis.cn/yun/23273.html

相關(guān)文章

  • 前端學(xué)習(xí)路線

    摘要:具體來說,包管理器就是可以通過命令行,幫助你把外部庫和插件放到你的項(xiàng)目里面并在之后進(jìn)行版本升級,這樣就不用手工復(fù)制和更新庫?,F(xiàn)在有的包管理器主要是和。 一、基礎(chǔ) 1、學(xué)習(xí)HTML基礎(chǔ) HTML給你的網(wǎng)頁賦予了結(jié)構(gòu)。它就像是人的骨架那樣讓你保持站立。首先你需要去學(xué)習(xí)語法以及它必須提供的一切。你的學(xué)習(xí)應(yīng)該聚焦在下面這些東西上: 學(xué)習(xí)HTML基礎(chǔ),了解如何編寫語義HTML 理解如何把網(wǎng)頁分...

    FullStackDeveloper 評論0 收藏0
  • 前端學(xué)習(xí)路線

    摘要:具體來說,包管理器就是可以通過命令行,幫助你把外部庫和插件放到你的項(xiàng)目里面并在之后進(jìn)行版本升級,這樣就不用手工復(fù)制和更新庫?,F(xiàn)在有的包管理器主要是和。 一、基礎(chǔ) 1、學(xué)習(xí)HTML基礎(chǔ) HTML給你的網(wǎng)頁賦予了結(jié)構(gòu)。它就像是人的骨架那樣讓你保持站立。首先你需要去學(xué)習(xí)語法以及它必須提供的一切。你的學(xué)習(xí)應(yīng)該聚焦在下面這些東西上: 學(xué)習(xí)HTML基礎(chǔ),了解如何編寫語義HTML 理解如何把網(wǎng)頁分...

    20171112 評論0 收藏0
  • 用什么PHP框架最好?框架?還不如用開源系統(tǒng)吧

    摘要:最近這六年來,一直使用開源系統(tǒng)來做項(xiàng)目,如等,雖然也有接觸過主流的框架,不過并不多?;ヂ?lián)網(wǎng)快速迭代我是互聯(lián)網(wǎng)比較早的用戶了,我學(xué)的時(shí)候還沒有所謂的框架,所以那時(shí)候開發(fā)出一個(gè)好用的框架無疑是提高生產(chǎn)力最佳的方案。 最近這六年來,一直使用PHP開源系統(tǒng)來做項(xiàng)目,如drupal, joomla, wordpress, magento等,雖然也有接觸過主流的框架,不過并不多。也許我會(huì)有一些偏見...

    Steven 評論0 收藏0
  • 「前端早讀君006」移動(dòng)開發(fā)必備:那些玩轉(zhuǎn)H5小技巧

    摘要:今日勵(lì)志語錄有志者自有千計(jì)萬計(jì),無志者只感千難萬難。三動(dòng)畫技術(shù)越來越不陌生,使用門檻也漸漸降低,而且動(dòng)畫還可以使用控制。掃一掃查看效果打開微掃一掃關(guān)注早讀君,每天早晨為你推送前端知識,度過擠地鐵坐公交的時(shí)光 今日勵(lì)志語錄有志者自有千計(jì)萬計(jì),無志者只感千難萬難。 文章原出處:騰訊ISUX 開始閱讀之前你可以先掃一掃體驗(yàn)demoshowImg(https://segmentfault.co...

    LittleLiByte 評論0 收藏0

發(fā)表評論

0條評論

最新活動(dòng)
閱讀需要支付1元查看
<