{"id":20341957,"url":"https://github.com/wongjn/vscode-php-sniffer","last_synced_at":"2025-07-24T16:40:23.188Z","repository":{"id":34188187,"uuid":"158557320","full_name":"wongjn/vscode-php-sniffer","owner":"wongjn","description":"Visual Studio Code extension for PHP_Codesniffer validation and formatting.","archived":false,"fork":false,"pushed_at":"2023-10-21T17:59:52.000Z","size":440,"stargazers_count":47,"open_issues_count":13,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T19:21:19.857Z","etag":null,"topics":["lint-php","php-codesniffer","php-sniffer","vscode-extension"],"latest_commit_sha":null,"homepage":"https://marketplace.visualstudio.com/items?itemName=wongjn.php-sniffer","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wongjn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-21T14:06:40.000Z","updated_at":"2025-03-24T17:41:21.000Z","dependencies_parsed_at":"2023-01-15T05:10:16.628Z","dependency_job_id":null,"html_url":"https://github.com/wongjn/vscode-php-sniffer","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wongjn%2Fvscode-php-sniffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wongjn%2Fvscode-php-sniffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wongjn%2Fvscode-php-sniffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wongjn%2Fvscode-php-sniffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wongjn","download_url":"https://codeload.github.com/wongjn/vscode-php-sniffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248495177,"owners_count":21113581,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lint-php","php-codesniffer","php-sniffer","vscode-extension"],"created_at":"2024-11-14T21:29:53.059Z","updated_at":"2025-04-11T23:34:19.373Z","avatar_url":"https://github.com/wongjn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PHP Sniffer\n\n[![Build Status](https://travis-ci.com/wongjn/vscode-php-sniffer.svg?branch=master)](https://travis-ci.com/wongjn/vscode-php-sniffer)\n[![PHP Sniffer on the Visual Studio Marketplace](https://vsmarketplacebadge.apphb.com/version-short/wongjn.php-sniffer.svg)](https://marketplace.visualstudio.com/items?itemName=wongjn.php-sniffer)\n\nUses [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) to format\nand lint (mainly) PHP code.\n\n## Features\n\n- Runs `phpcs` to lint code.\n- Runs `phpcbf` to format fixable code validation errors, using the built-in\n  commands \"Format Document\" or \"Format Selection\" (PHP only).\n  - One may need to set this extension as the default language formatter for\n    some languages. The following snippet is an example for PHP that can be\n    added in a `settings.json`:\n    ```json\n    {\n      \"[php]\": {\n        \"editor.defaultFormatter\": \"wongjn.php-sniffer\"\n      }\n    }\n    ```\n\n## Requirements\n\n- [PHP](https://php.net)\n- [PHP_Codesniffer](https://github.com/squizlabs/PHP_CodeSniffer)\n\n## Extension Settings\n\n### Quick Setup\n\n`settings.json`:\n\n```json\n{\n  \"phpSniffer.autoDetect\": true\n}\n```\n\nAnd if your projects look like this:\n\n```\nworkspace-folder/\n  vendor/\n    bin/\n      phpcs\n      phpcbf\n  .phpcs.xml\n```\n\nValidation and formatting will work (see below for alternative filenames for\n`.phpcs.xml`).\n\n### In Depth\n\nThis extension contributes the following settings:\n\n* `phpSniffer.run`: When to run `phpcs` (the linter). Can be `onSave`, `onType`\nor `never`.\n* `phpSniffer.onTypeDelay`: When `phpSniffer.run` is `onType`, this sets the\namount of milliseconds the validator will wait after typing has stopped before\nit will run. The validator will also cancel an older run if the run is on the\nsame file.\n* `phpSniffer.extraFiles`: [Glob patterns](https://code.visualstudio.com/api/references/vscode-api#GlobPattern)\nof extra files to match that this extension should run on. Useful for standards\nthat don't just validate PHP files. This extension will **always** run on PHP\nfiles — be sure to have your `files.associations` setting correctly setup for\nPHP files.\n* `phpSniffer.executablesFolder`: The **folder** where both `phpcs` and `phpcbf`\nexecutables are. Use this to specify a different executable if it is not in your\nglobal `PATH`, such as when using `PHP_Codesniffer` as a project-scoped\ndependency. Can be absolute, or relative to the workspace folder.\n* `phpSniffer.autoDetect`: Set to `true` for the extension to auto-detect\n`phpSniffer.executablesFolder` as `./vendor/bin/` per workspace folder (applies\nonly if `phpSniffer.executablesFolder` is empty).\n* `phpSniffer.standard`: The standards to check against. This is passed to the\n`phpcbf` and `phpcs` executables as the value for `--standard`. Can be absolute,\nor relative to the workspace folder. If not set,\n[PHP_CodeSniffer will attempt to find a file to use](https://github.com/squizlabs/PHP_CodeSniffer/wiki/Advanced-Usage#using-a-default-configuration-file),\nat the root of the currently open file's workspace folder in the following order:\n  1. `.phpcs.xml`\n  2. `phpcs.xml`\n  3. `.phpcs.xml.dist`\n  4. `phpcs.xml.dist`\n* `phpSniffer.snippetExcludeSniffs`: Sniffs to exclude when formatting a PHP\ncode snippet (such as when _formatting on paste_ or on the command\n`format on selection`). This is passed to the `phpcbf` command as the value for\n`--exclude` when **not** formatting a whole file.\n* `phpSniffer.disableWhenDebugging`: Disable sniffing when any debug session is\nactive.\n\n## Known Issues\n\n### Windows Hanging PHP Process\n\nWhen `phpcs` encounters a malformed array declaration, [it can sometimes hang from an error](https://github.com/squizlabs/PHP_CodeSniffer/issues/2142).\nThis is exacerbated by the fact that we do not have access to the spawned `php`\nprocess in the extension code and cannot kill `php.exe` directly. This causes\nmany non-exiting PHP processes on Windows machines which can really slow down\nthe machine.\nThe fix for this is to update `squizlabs/PHP_Codesniffer` in use to `\u003e=3.4.2`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwongjn%2Fvscode-php-sniffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwongjn%2Fvscode-php-sniffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwongjn%2Fvscode-php-sniffer/lists"}