← Back to felixfbecker/vscode-php-intellisense

How to Deploy & Use felixfbecker/vscode-php-intellisense

PHP IntelliSense for VS Code - Deployment & Usage Guide

Prerequisites

For End Users

  • Visual Studio Code (latest stable version recommended)
  • PHP >= 7.0.0 (must be accessible in system PATH or configured via settings)
  • Git (optional, for cloning sample projects)

For Development/Contribution

  • Node.js (LTS version recommended)
  • npm (comes with Node.js)
  • Composer (PHP dependency manager)
  • PHP >= 7.0.0 with CLI support
  • Visual Studio Code with Extension Development support
  • vsce (VS Code Extension CLI tool) for packaging:
    npm install -g vsce
    

Installation

Option A: End User Installation (Marketplace)

  1. Open VS Code
  2. Go to Extensions view (Ctrl+Shift+X / Cmd+Shift+X)
  3. Search for "PHP IntelliSense" by Felix Becker
  4. Click Install
  5. Disable built-in PHP IntelliSense to avoid duplicate suggestions:
    {
      "php.suggest.basic": false
    }
    

Option B: Manual Installation (VSIX)

  1. Download the latest .vsix from releases or build locally (see Build section)
  2. In VS Code, go to Extensions view → ... menu → Install from VSIX
  3. Select the downloaded file

Option C: Development Installation (Source)

  1. Clone the repository:

    git clone https://github.com/felixfbecker/vscode-php-intellisense.git
    cd vscode-php-intellisense
    
  2. Install PHP dependencies (language server):

    composer install
    
  3. Install Node.js dependencies:

    npm install
    

Configuration

Required Settings

Add to your VS Code settings.json (Ctrl+, then search settings):

SettingDescriptionExample
php.executablePathPath to PHP binary if not in PATH"C:\\php\\php.exe" (Windows) or "/usr/bin/php" (Linux/Mac)
php.memoryLimitMemory limit for language server"4095M" (default), "2G", or "-1" for unlimited

Recommended Settings

{
  "php.suggest.basic": false,
  "php.executablePath": "/usr/bin/php",
  "php.memoryLimit": "4095M"
}

Memory Limit Validation Rules:

  • Must be numeric with optional suffix (K, M, G)
  • Or -1 for unlimited
  • Examples: 512M, 2G, 4095M, -1

Environment Variables

Ensure php command is available in your shell PATH, or explicitly configure php.executablePath.

Build & Run

Development Workflow

  1. Install dependencies:

    composer install
    npm install
    
  2. Build the extension:

    npm run build
    
  3. Launch Development Host:

    • Open the project folder in VS Code: code .
    • Press F5 to launch the Extension Development Host
    • A new VS Code window opens with the extension loaded
    • Open any PHP file to test IntelliSense features

Working on the Language Server

The PHP language server is bundled via Composer in vendor/felixfbecker/language-server. To use a local development version:

  1. Clone the language server repository separately
  2. Replace the vendor directory with a symlink:
    rm -rf vendor/felixfbecker/language-server
    ln -s /path/to/your/php-language-server vendor/felixfbecker/language-server
    

Production Build

Create a deployable VSIX package:

npm run build
vsce package

This generates a .vsix file for distribution.

Deployment

Publishing to VS Code Marketplace

  1. Prerequisites:

    • Azure DevOps Personal Access Token with Marketplace permissions
    • Publisher account on VS Code Marketplace
  2. Login:

    vsce login <publisher-name>
    
  3. Publish:

    vsce publish
    

    Or for specific version:

    vsce publish patch  # or minor/major
    

Enterprise/Offline Deployment

For air-gapped environments or enterprise distribution:

  1. Build the VSIX: vsce package
  2. Distribute the .vsix file via internal extension gallery or file share
  3. Users install via Command Palette → Extensions: Install from VSIX

CI/CD Integration (Travis CI)

The project uses Travis CI for automated builds (see .travis.yml):

  • Builds run on every push/PR
  • Semantic-release automates versioning and publishing
  • Ensure GH_TOKEN and VSCE_TOKEN are set in Travis environment variables

Troubleshooting

PHP Executable Not Found

Error: PHP executable not found. Install PHP 7 and add it to your PATH...

Solutions:

  1. Verify PHP installation: php --version (should show >= 7.0.0)
  2. Set explicit path in settings:
    • Windows: "php.executablePath": "C:\\php\\php.exe"
    • Linux/Mac: "php.executablePath": "/usr/bin/php"
  3. Restart VS Code after changing settings

Invalid Memory Limit

Error: The memory limit you\'d provided is not numeric...

Solution: Use valid PHP shorthand notation:

  • Correct: "4095M", "2G", "-1"
  • Incorrect: "4095 MB", "unlimited"

PHP Version Compatibility

Error: Spawning PHP fails or features don't work

Check: Run php --version in terminal. Must be >= 7.0.0. The extension checks for semantic version ^7.0.0.

Duplicate Suggestions

Issue: Seeing double completion suggestions

Solution: Disable VS Code's built-in PHP IntelliSense:

{
  "php.suggest.basic": false
}

Language Server Crashes

Symptom: Features stop working, high CPU usage

Solutions:

  1. Increase memory limit: "php.memoryLimit": "-1" (unlimited) or "8G"
  2. Check Output panel → "PHP IntelliSense" for stack traces
  3. Ensure no conflicting PHP extensions are installed (disable other IntelliSense providers)

Development: Extension Won't Launch

Issue: F5 doesn't open Extension Development Host

Solutions:

  1. Ensure npm run build completed without errors
  2. Check that composer install ran successfully (vendor directory exists)
  3. Verify TypeScript compilation: check out/ directory exists with compiled .js files

Windows-Specific Issues

If using WSL or Cygwin paths, ensure php.executablePath uses Windows-style paths or WSL paths consistently with your VS Code environment.