介紹幾個非常不錯的工具,來幫助程序員們提高自己的工作效率,一起來看看吧!
1 PHP Parser : https://github.com/nikic/PHP-Parser
PHP-Parser是一個用PHP編寫的PHP解析器(支持PHP 5.4以及更早的版本),這種特殊的解析器非常適合靜態代碼分析。該工具的目的就是簡化靜態代碼分析和操作,它使程序員能夠以編程的方式來處理任何應用程序的代碼。
2 PHPSandbox : https://github.com/fieryprophet/php-sandbox
PHPSandbox將運行PHP作為獨立進程的一種方式。 它為程序員提供一種外圍腳本的保護,比如錯誤、崩潰、運行慢的腳本,或者不適合在代碼中運行的腳本,都可作為獨立進程來運行。
3 PHP Mess Detector : https://phpmd.org/
PHPMD這個工具能夠探測PHP源代碼中一些潛在的問題。例如:
- 可能存在的Bug
- 未達最佳標准的代碼
- 過於復雜的語法
- 從未使用過的參數、方法、屬性
4 PHPCPD : https://github.com/sebastianbergmann/phpcpd
PHPCPD是一個在代碼中尋找類似模式的工具,使用它是為了在代碼庫中識別代碼在何處被復制或粘貼。這是常規構建過程中一個非常有用的工具,它會幫助程序員分析代碼,以避免在代碼庫中重復調用函數。
5 PHPCheckstyle : https://phpcheckstyle.github.io/
PHPCheckstyle是一個幫助PHP程序員檢查代碼和報告錯誤的工具,運行於PHP 5.0以及更高的版本。通過SVN鈎子腳本的方式來調用PHPCheckstyle,可以強制代碼必須符合預先設定的編碼標准(比如PEAR編碼標准),有助於在多人合作項目中提高代碼整體質量。
6 Ubench : https://github.com/devster/ubench
Ubench是一個用於評測PHP代碼執行時間和內存使用效率的開發庫。使用方法如下:
require_once 'src/Ubench.<span id="1_nwp" style="width: auto; height: auto; float: none;"><a id="1_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=18&is_app=0&jk=52d10cc8a331984b&k=php&k0=php&kdi0=0&luki=8&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=4b9831a3c80cd152&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F6257%2Ehtml&urlid=0" target="_blank" mpid="1" style="text-decoration: none;"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">php</span></a></span>'; $bench = new Ubench; $bench->start(); // Execute some code $bench->end(); // Get elapsed time and <span id="2_nwp" style="width: auto; height: auto; float: none;"><a id="2_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=18&is_app=0&jk=52d10cc8a331984b&k=memory&k0=memory&kdi0=0&luki=4&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=4b9831a3c80cd152&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F6257%2Ehtml&urlid=0" target="_blank" mpid="2" style="text-decoration: none;"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">memory</span></a></span> echo $bench->getTime(); // 156ms or 1.123s echo $bench->getTime(true); // elapsed microtime in float echo $bench->getTime(false, '%d%s'); // 156ms or 1s echo $bench->getMemoryPeak(); // 152B or 90.00Kb or 15.23Mb echo $bench->getMemoryPeak(true); // memory <span id="3_nwp" style="width: auto; height: auto; float: none;"><a id="3_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=18&is_app=0&jk=52d10cc8a331984b&k=peak&k0=peak&kdi0=0&luki=3&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=4b9831a3c80cd152&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F6257%2Ehtml&urlid=0" target="_blank" mpid="3" style="text-decoration: none;"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">peak</span></a></span> in bytes echo $bench->getMemoryPeak(false, '%.3f%s'); // 152B or 90.152Kb or 15.234Mb // Returns the memory usage at the end <span id="4_nwp" style="width: auto; height: auto; float: none;"><a id="4_nwl" href="http://cpro.baidu.com/cpro/ui/uijs.php?adclass=0&app_id=0&c=news&cf=1001&ch=0&di=128&fv=18&is_app=0&jk=52d10cc8a331984b&k=mark&k0=mark&kdi0=0&luki=2&n=10&p=baidu&q=06011078_cpr&rb=0&rs=1&seller_id=1&sid=4b9831a3c80cd152&ssp2=1&stid=0&t=tpclicked3_hc&tu=u1922429&u=http%3A%2F%2Fwww%2Eadmin10000%2Ecom%2Fdocument%2F6257%2Ehtml&urlid=0" target="_blank" mpid="4" style="text-decoration: none;"><span style="color:#0000ff;font-size:14px;width:auto;height:auto;float:none;">mark</span></a></span> echo $bench->getMemoryUsage(); // 152B or 90.00Kb or 15.23Mb
7 PHP Analyzer : https://scrutinizer-ci.com/docs/tools/php/php-analyzer/
PHP Analyzer執行和編譯器相同的流動分析,確保代碼在每個潛在執行路徑的每一行都執行了測試。這種特殊的工具幫助開發人員提高了自己的代碼質量,從而確保了工作效率。