mac Atom php静态代码检查phpcs,phpmd

首先 你的mac 得安装atom

你的mac有PHP环境

linter-phpcs 主要检查格式 linter-phpmd主要检查语法

1、sudo  pear install PHP_CodeSniffer

如果一切正常的话,你执行phpcs --version可以看到版本号了。
执行phpcs -i可以看到它已经预先安装好一些标准了:

The installed coding standards are MySource, PEAR, PHPCS, PSR1, PSR2, Squiz, Zend

一般第一次会遇到


Warning: include_once(PHP/CodeSniffer/CLI.php): failed to open stream: No such file or directory in /usr/local/bin/phpcs on line 21

Warning: include_once(): Failed opening 'PHP/CodeSniffer/CLI.php' for inclusion (include_path='.:') in /usr/local/bin/phpcs on line 21

Fatal error: Class 'PHP_CodeSniffer_CLI' not found in /usr/local/bin/phpcs on line 24

用以下命令找出路径

pear config-get php_dir

我的执行结果是:‘/usr/lib/php/pear’

然后修改php.ini,添加或修改一行

include_path = ".:/usr/lib/php/pear"

再执行phpcs -i 就正常了。

 

配置文件: /usr/lib/php/pear/data/PHP_CodeSniffer/CodeSniffer.conf

这样PHP_CodeSniffer就安装好了 。

接下来就是配置Atom 插件了。

安装linter-phpcs 插件。启用  这样就可以用了 。(无需配置)

系统中安装phpmd

composer global require phpmd/phpmd

系统中安装linter-phpmd插件

apm install linter-phpmd

安装完后来测试可以看到系统中。有了phpmd命令。
这时再Atom中编辑php文件就会自动检查了。

在linter-phpmd安装的过程中我的出现了如下故障:

[Linter] Error running PHPMD Error: Failed to spawn command `phpmd`. Make sure `phpmd` is installed and on your PATH(…)

解决方法:

找到本地phpmd 的安装路径:我的/Users/eric/.composer/vendor/bin

然后 

也可以直接编辑  ~/.atom/init.coffee这个文件。

 

最终效果

 

phpstorm 上安装这些插件参考:http://confluence.jetbrains.com/display/PhpStorm/PHP+Mess+Detector+in+PhpStorm#PHPMessDetectorinPhpStorm-1.EnablePHPMessDetectorintegrationinPhpStorm

编辑自定义规则参考:http://www.kancloud.cn/bajiao/phpmd/128478

关于“mac Atom php静态代码检查phpcs,phpmd”我的62个想法

  1. Pingback: sex drug
  2. Pingback: CBD gummies
  3. Pingback: best CBD oil
  4. Pingback: CBD gummies
  5. Pingback: education
  6. Pingback: scraping api
  7. Pingback: best Royal CBD oil
  8. Pingback: CBD oil
  9. Pingback: CBD oil for sale
  10. Pingback: CBD oil
  11. Pingback: best CBD gummies
  12. Pingback: CBD gummies
  13. Pingback: best CBD capsules
  14. Pingback: Royal CBD
  15. Pingback: Royal CBD
  16. Pingback: CBD products
  17. Pingback: carte prepagate
  18. Pingback: CBD
  19. Pingback: paddle board
  20. Pingback: Nairobiwire
  21. Pingback: apps for pc download
  22. Pingback: app for pc download
  23. Pingback: dispensaries near me
  24. Pingback: finger vibe
  25. Pingback: thrusting massager
  26. Pingback: remote control bullet
  27. Pingback: CBD capsules
  28. Pingback: CBD store
  29. Pingback: CBD for sale
  30. Pingback: CBD gummies
  31. Pingback: CBD oil
  32. Pingback: CBD gummies
  33. Pingback: CBD capsules
  34. Pingback: CBD gummies
  35. Pingback: Cannabis oil for sale
  36. Pingback: beginner strap on
  37. Pingback: CBD cream
  38. Pingback: anal play
  39. Pingback: Atta chakki
  40. Pingback: extender sleeve
  41. Pingback: dank vapes
  42. Pingback: CBD products
  43. Pingback: Royal CBD
  44. Pingback: CBD oil
  45. Pingback: doctor7online.com
  46. Pingback: Cockatoo
  47. Pingback: Buy Dmt
  48. Pingback: Grand Power Stribog
  49. Pingback: Buy Marijuana Online
  50. Pingback: cialis 20mg

发表评论

电子邮件地址不会被公开。 必填项已用*标注