Skip to content

Pilot-in/PilotIn-Coding-Standards

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

35 Commits
Β 
Β 
Β 
Β 

Repository files navigation

PilotIn-Coding-Standards

PHP Coding Standards of Pilot'in (inspired & respecting mostly WordPress Coding Standards)

Installation steps

  • Having composer installed:

Get Composer

  • Having PHP Code Sniffer installed:

composer global require "squizlabs/php_codesniffer=*"

  • Having WordPress Coding Standards installed:

composer global require dealerdirect/phpcodesniffer-composer-installer phpcompatibility/phpcompatibility-wp squizlabs/php_codesniffer wp-coding-standards/wpcs

  • Clone this repo somewhere on your drive (or you can just download this repo and unzip it but it's not going to be synced / updated)
  • Get the current path config of phpcs using:

phpcs --config-show

  • Copy the paths after "installed_paths:"
  • Paste it somewhere and append the path of your folder containing the "PilotIn" folder with a comma

For reference, mine looks like this: C:\composer\vendor/phpcompatibility/php-compatibility,C:\composer\vendor/phpcompatibility/phpcompatibility-paragonie,C:\composer\vendor/phpcompatibility/phpcompatibility-wp,C:\composer\vendor/wp-coding-standards/wpcs,C:\Users\Administrateur\Documents\PLUGINS DEV\PilotIn-Coding-Standards\PilotIn

⚠️ If you have relative paths, replace them by absolute paths!

  • Give the new paths to phpcs using this command & change your/paths/goes/here:

phpcs --config-set installed_paths your/paths/goes/here

Example: phpcs --config-set installed_paths C:\composer\vendor/phpcompatibility/php-compatibility,C:\composer\vendor/phpcompatibility/phpcompatibility-paragonie,C:\composer\vendor/phpcompatibility/phpcompatibility-wp,C:\composer\vendor/wp-coding-standards/wpcs,C:\Users\Administrateur\Documents\PLUGINS DEV\PilotIn-Coding-Standards\PilotIn

  • Set the default standard as PilotIn using:

phpcs --config-set default_standard PilotIn

  • Restart your terminal to be sure everything is up to date & try this command to see if everything is set:

phpcs -i

(You should have "PilotIn" showing & you're good to go πŸš€)

Bonus steps

VS Code

  • Install wongjn.php-sniffer extension (VS Marketplace)
  • Add this to your vscode settings json (Ctrl + Shift + P > Settings json):
"php.validate.executablePath": "C:/Full/Path/To/php.exe",
"php.validate.run": "onType",
"[php]": {
    "editor.defaultFormatter": "wongjn.php-sniffer"
},
"phpSniffer.standard": "PilotIn",
"phpSniffer.executablesFolder": "C:/Full/Path/To/Composer/vendor/bin",
"phpSniffer.run": "onSave",
"editor.formatOnSave": true,

Make sure that your paths (both to php.exe and to the phpcs and phpcbf executables) are correct and absolute. Use the full path every time.

PhpStorm

  • Go to Files > Settings > PHP > Quality Tools

phpcs_1

  • Select your files

image

  • Then go to Editor > Inspections > PHP > Quality tools > PHP_CodeSniffer validation and select PilotIn in Coding standard option. You can also choose what type of warning it'll trigger

phpcs_2

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •