How can I use phpcs in sublime to find out the coding standards?

I want to learn how to code PHP according to the standard. I found this article and (on her advice) installed phpcs in exalted text 2. If I go to tools -> phpcode sniffers -> sniff this file, it will find syntax errors, but it does not code standard deviations. (Here is the code I'm trying to smell, which I think has a lot of deviations from the standard https://codereview.stackexchange.com/questions/57045/simple-wrapper-for-an-api ).

docs say to configure phpcs to use the coding standard through phpcs_additional_args. If I go to sublimetext2-> preferences-> package-> phpcode sniffer-> settings, I see the following code:

   "phpcs_additional_args": {
        "--standard": "PSR2",
        "-n": ""
    },

Here is my complete configuration file .

Do I have a workflow? If so, why doesn't he find my mistakes? How to use phpcs to teach coding standards? Even knowing that I am taking the right steps, but the plugin does not display standard coding labels, it would be useful.

+4
source share
3 answers

Depending on your configuration file, there are some things you should fix:

linux (ubuntu) mac

  • , PEAR
  • php

    pear install PHP_CodeSniffer

    bash zsh, , , ,

    which phpcs

    "phpcs_executable_path": phpcs

    "phpcs_executable_path": php, phpcs,

  • php mess

    pear channel-discover pear.phpmd.org pear channel-discover pear.pdepend.org pear install pdepend/PHP_Depend pear install --alldeps phpmd/PHP_PMD

    phpcs

    which phpmd, "phpmd_executable_path": "" phpcs

  • php-cs-fixer

    sudo wget http://get.sensiolabs.org/php-cs-fixer.phar -O /usr/local/bin/php-cs-fixer sudo chmod a+x /usr/local/bin/php-cs-fixer

    "php_cs_fixer_executable_path": "" "php_cs_fixer_executable_path": "/usr/local/bin/php-cs-fixer"

  • scheck

    cd /opt/ git clone --depth=1 https://github.com/facebook/pfff.git cd pfff/ ./configure make depend make make opt

    "scheck_executable_path" "scheck_executable_path": "/opt/pfff/scheck"

: sudo pear ... pear ...

+9
+2

after saving your .php file, right click and release Php Code Sniffer and you will see the options.

enter image description here

0
source

All Articles