vscode-phpcs

January 10, 2026 · View on GitHub

CI codecov Snyk Security CodeRabbit Pull Request Reviews

PlatformVersionInstallsRating
VS MarketplaceVS Code Marketplace VersionVS Code Marketplace InstallsVS Code Marketplace Rating
Open VSXOpen VSX VersionOpen VSX DownloadsOpen VSX Rating

Integrates phpcs (PHP_CodeSniffer) for linting and phpcbf (PHP Code Beautifier and Fixer) for auto-fixing code style issues into VS Code and compatible editors.

Extension History

This extension is the actively maintained continuation of the original PHPCS extensions:

  • ikappas.phpcs (versions 1.0.1 – 1.0.4) — The original extension by Ioannis Kappas
  • shevaua.phpcs (versions 1.0.6 – 1.0.8) — Maintained by Igor Sheviakov

Both previous extensions are no longer maintained. This fork continues development with new features, bug fixes, and support for PHP_CodeSniffer v4.

Note for Open VSX users: This extension was previously published on the Open VSX Registry as johnrdorazio.phpcs (versions 1.1.0 – 1.2.1). That extension ID is now deprecated in favor of johnrdorazio.vscode-phpcs. Please uninstall the old extension and install this one to receive future updates.

If you were using any of the previous extensions, you can safely uninstall them and switch to this one to receive continued updates.

Supports PHPCS versions 1.x, 2.x, 3.x, and 4.x.

Note: This extension requires a local Node.js runtime and does not work on web platforms (github.dev, vscode.dev). It needs to spawn PHPCS as a child process, which is not possible in browser-based environments.

For release notes and version history, see the Changelog.

Setup Development Version

Prerequisites

  • Node.js v20 or later
  • VS Code v1.106.3 or later (or compatible editor)

Installation

  1. Clone this repository and check out the develop branch

  2. Open the cloned repository folder using VS Code

  3. Install dependencies from the root directory:

    npm install
    

    This runs postinstall scripts that install dependencies for both phpcs-server/ and phpcs/ subdirectories.

Building

To build the extension, run from the root directory:

npm run bundle        # Production build (minified)
npm run bundle-dev    # Development build (with sourcemaps)

This uses esbuild to bundle both the client and server into single JavaScript files in phpcs/dist/.

To create a .vsix package for installation:

npm run package-prod  # Production package (~177KB compressed)
npm run package-dev   # Development package with sourcemaps (~388KB compressed)

Running Tests

npm test

This runs tests for both the server and client.

Run/Debug Development Version

To run the development version of the phpcs extension:

  1. Open the cloned repository folder using VS Code

  2. (Optional) Build the extension before debugging to ensure artifacts are ready:

    npm run bundle-dev         # One-time build
    # OR
    npm run bundle-watch       # Continuous watch mode (auto-rebuilds on changes)
    

    Note: The debug configurations automatically start the watch tasks via preLaunchTask, but running bundle-dev first ensures the initial build completes before the extension launches.

  3. Select sidebar option Run and Debug (Ctrl+Shift+D)

  4. Select Client + Server from the Debug dropdown menu

  5. Press Start Debugging (F5)

This will launch a new VS Code window named Extension Development Host, automatically using the development version of the phpcs extension.

Note: If you don't have an open PHP file in the Extension Development Host, the server debug session will timeout and you will need to relaunch it from the debug panel.

Architecture

This extension uses the Language Server Protocol (LSP) architecture, which separates the extension into two components:

  • Client (phpcs/): The VS Code extension that communicates with the editor
  • Server (phpcs-server/): A separate Node.js process that runs PHPCS and reports diagnostics

Why LSP?

The LSP architecture provides several benefits:

  1. Non-blocking linting: The server runs in a separate process, so heavy PHPCS operations don't freeze the VS Code UI
  2. Better resource isolation: Memory and CPU usage are isolated from the main extension host
  3. Standardized protocol: Uses the same protocol as other language servers, making the codebase more maintainable

Extension Size

This extension is larger (~650KB uncompressed) compared to simpler alternatives (~185KB) because it bundles the LSP libraries:

ComponentSize
vscode-languageclient~100KB
vscode-languageserver~80KB
vscode-languageserver-protocol~45KB
vscode-jsonrpc~35KB
Other dependencies~40KB
Extension code~10KB

The trade-off is worth it: the LSP approach ensures VS Code remains responsive even when linting large files or projects with many PHP files.