PHP Intelephense: Complete Setup and Configuration Guide for VS Code

PHP Intelephense is the extension that turns VS Code into a proper PHP IDE. Without it you get basic syntax highlighting. With it you get intelligent code completion, real-time error detection, go-to definition, find all references, automatic imports, and a formatter that follows PHP-FIG standards – all running locally without sending your code anywhere.

This guide covers installing PHP Intelephense, the critical setup step most tutorials skip, the configuration settings that actually matter, and fixes for the most common problems developers hit.

What PHP Intelephense Does

VS Code ships with built-in PHP support but it’s limited. VS Code does not offer the same level of support and functionality out-of-the-box for PHP as it does for TypeScript. While it does come with built-in PHP support, it lacks the more advanced features essential for efficient PHP development.

PHP Intelephense fills that gap with:

  • Intelligent code completion – suggests methods, properties, and functions as you type based on actual type information, not just text matching
  • Real-time diagnostics – syntax errors, type errors, and language constraint violations highlighted as you write
  • Go to definition – jump to any class, method, or function definition with one click
  • Find all references – see everywhere a method or variable is used across the entire project
  • Hover documentation – PHPDoc documentation appears on mouse hover
  • Automatic imports – adds use statements automatically when you reference a class
  • Code formatting – formats to PHP-FIG coding standards
  • Rename symbols – safely rename a method or class across all files at once

For full feature documentation see the official PHP Intelephense documentation.

Installing PHP Intelephense

Open VS Code and press Ctrl + Shift + X to open the Extensions panel. Search for “intelephense” and install the extension by bmewburn:

Extension ID: bmewburn.vscode-intelephense-client

Alternatively install from the command line:

code --install-extension bmewburn.vscode-intelephense-client

Verify installation:

code --list-extensions | grep intelephense

Output:

bmewburn.vscode-intelephense-client

The Critical Step Most Tutorials Skip

Installing Intelephense is not enough. VS Code’s built-in PHP Language Features extension must be disabled to prevent conflicts. Both extensions provide overlapping functionality that interferes with each other.

If you skip this step you’ll get duplicate suggestions, slower performance, and inconsistent behavior.

How to disable PHP Language Features:

  1. Press Ctrl + Shift + X to open Extensions
  2. Search for “PHP Language Features”
  3. Click the gear icon next to it
  4. Select Disable

Important: Leave PHP Language Basics enabled for syntax highlighting. Only disable PHP Language Features. They are two separate extensions.

The difference:

PHP Language Basics    ← KEEP ENABLED (syntax highlighting)
PHP Language Features  ← DISABLE (conflicts with Intelephense)

Verifying It Works

Open any PHP file and test these:

<?php

class UserService
{
    private UserRepository $repository;

    public function __construct(UserRepository $repository)
    {
        $this->repository = $repository;
    }

    public function findById(int $id): ?User
    {
        return $this->repository->find($id);
    }
}

Type $this-> inside a method and you should see repository suggested with its type. Hover over $this->repository and you should see the type information. Press F12 on any method name to jump to its definition.

If none of that works, PHP Language Features is still enabled or Intelephense hasn’t finished indexing your project yet. Check the status bar at the bottom of VS Code – it shows “Indexing” while processing.

Essential Configuration Settings

Open your VS Code settings JSON file with Ctrl + Shift + P then search “Open User Settings JSON”. Add these settings:

{
    // Tell Intelephense which PHP version your project uses
    "intelephense.environment.phpVersion": "8.2.0",

    // Format PHP files automatically on save
    "[php]": {
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "bmewburn.vscode-intelephense-client"
    },

    // Exclude vendor and cache directories from indexing
    "intelephense.files.exclude": [
        "**/.git/**",
        "**/.svn/**",
        "**/.hg/**",
        "**/CVS/**",
        "**/.DS_Store/**",
        "**/node_modules/**",
        "**/bower_components/**",
        "**/vendor/**/{Tests,tests}/**",
        "**/.history/**",
        "**/vendor/**/vendor/**",
        "**/storage/**",
        "**/cache/**"
    ],

    // Maximum file size to index (default 1MB)
    "intelephense.files.maxSize": 5000000,

    // Enable/disable specific diagnostics
    "intelephense.diagnostics.enable": true,
    "intelephense.diagnostics.undefinedTypes": true,
    "intelephense.diagnostics.undefinedFunctions": true,
    "intelephense.diagnostics.undefinedConstants": true,
    "intelephense.diagnostics.undefinedVariables": true,

    // Code completion settings
    "intelephense.completion.insertUseDeclaration": true,
    "intelephense.completion.fullyQualifyGlobalConstantsAndFunctions": false,
    "intelephense.completion.triggerParameterHints": true,

    // Telemetry off
    "intelephense.telemetry.enabled": false
}

Setting the Correct PHP Version

The PHP version setting is important – it determines which language features and functions Intelephense treats as valid. If it’s set incorrectly you’ll get false errors for valid code or miss errors for deprecated functions:

// For PHP 8.0 projects
"intelephense.environment.phpVersion": "8.0.0"

// For PHP 8.1 (enums, fibers, readonly properties)
"intelephense.environment.phpVersion": "8.1.0"

// For PHP 8.2 (readonly classes, DNF types)
"intelephense.environment.phpVersion": "8.2.0"

// For PHP 8.3 (typed class constants, json_validate)
"intelephense.environment.phpVersion": "8.3.0"

// For PHP 8.4 (property hooks, asymmetric visibility)
"intelephense.environment.phpVersion": "8.4.0"

Check your installed PHP version if unsure:

php --version

Output:

PHP 8.2.17 (cli) (built: Mar 15 2026)
Copyright (c) The PHP Group

Configuring Stubs for PHP Extensions

Stubs provide type information for PHP extensions like cURL, PDO, and MySQLi. Intelephense includes 170+ PHP extension stubs. The intelephense.stubs array setting controls which PHP extension type information is loaded.

Add the extensions your project uses:

"intelephense.stubs": [
    "apache",
    "bcmath",
    "bz2",
    "calendar",
    "com_dotnet",
    "Core",
    "ctype",
    "curl",
    "date",
    "dba",
    "dom",
    "enchant",
    "exif",
    "FFI",
    "fileinfo",
    "filter",
    "fpm",
    "ftp",
    "gd",
    "gettext",
    "gmp",
    "hash",
    "iconv",
    "imap",
    "intl",
    "json",
    "ldap",
    "libxml",
    "mbstring",
    "meta",
    "mysqli",
    "oci8",
    "odbc",
    "openssl",
    "pcntl",
    "pcre",
    "PDO",
    "pdo_ibm",
    "pdo_mysql",
    "pdo_pgsql",
    "pdo_sqlite",
    "pgsql",
    "Phar",
    "posix",
    "pspell",
    "random",
    "readline",
    "Reflection",
    "session",
    "SimpleXML",
    "snmp",
    "soap",
    "sockets",
    "sodium",
    "SPL",
    "sqlite3",
    "standard",
    "superglobals",
    "sysvmsg",
    "sysvsem",
    "sysvshm",
    "tidy",
    "tokenizer",
    "xml",
    "xmlreader",
    "xmlrpc",
    "xmlwriter",
    "xsl",
    "Zend OPcache",
    "zip",
    "zlib"
]

For PHP web scraping projects specifically, make sure curl, PDO, pdo_mysql, dom, and SimpleXML are in the list – these are used in every scraping project.

Workspace vs User Settings

Settings can be applied globally (user settings) or per project (workspace settings). For the PHP version setting, use workspace settings so different projects can use different PHP versions:

# Create workspace settings for your project
mkdir -p .vscode
touch .vscode/settings.json
// .vscode/settings.json - project specific settings
{
    "intelephense.environment.phpVersion": "8.1.0",
    "intelephense.files.exclude": [
        "**/vendor/**/{Tests,tests}/**",
        "**/storage/**",
        "**/bootstrap/cache/**"
    ]
}

Commit .vscode/settings.json to your repository so every developer on the team uses the same settings. Add secrets or machine-specific settings to user settings instead.

Non-Standard PHP File Extensions

Some projects use non-standard extensions for PHP files – .module in Drupal, .inc for include files, .phtml for templates. Add glob patterns for non-standard PHP file extensions to the files.associations setting.

// In settings.json
"files.associations": {
    "*.module":  "php",
    "*.inc":     "php",
    "*.phtml":   "php",
    "*.install": "php",
    "*.theme":   "php"
}

After adding these, Intelephense treats those files as PHP and provides full intelligence including completions, diagnostics, and formatting.

Key Features and How to Use Them

Go to Definition (F12)

<?php
$pdo = new PDO($dsn, $user, $pass);
// Press F12 on PDO to see the stub definition
// Press F12 on any of your own classes to jump to the file

$service = new UserService();
$service->findById(42);
// F12 on findById() jumps directly to the method

Find All References (Shift + F12)

<?php
// Place cursor on method name
// Press Shift + F12
// VS Code shows every place this method is called
// Across the entire project

public function findById(int $id): ?User
{
    // Shift + F12 here shows all call sites
}

Rename Symbol (F2)

<?php
// Place cursor on any method, class, or variable name
// Press F2
// Type the new name
// Intelephense renames it everywhere in the project safely

Automatic Use Statement Insertion

<?php

namespace App\Http\Controllers;

class UserController extends Controller
{
    public function store(Request $request): RedirectResponse
    // Start typing Request - Intelephense suggests it
    // Accept the suggestion and it auto-adds:
    // use Illuminate\Http\Request;
    // use Illuminate\Http\RedirectResponse;
    // at the top of the file
    {
    }
}

Format on Save

With "editor.formatOnSave": true in your settings, saving any PHP file automatically formats it to PHP-FIG standards. Inconsistent indentation, spacing around operators, and brace placement get fixed every time you save.

Common Problems and Fixes

Intelephense Not Providing Completions

# Check 1: Is PHP Language Features still enabled?
# Extensions panel → search "PHP Language Features" → Disable

# Check 2: Is Intelephense still indexing?
# Look at the VS Code status bar for "Intelephense indexing"
# Wait for it to complete on large projects

# Check 3: Is the file associated with PHP?
# Check bottom-right of VS Code status bar
# Should show "PHP" not "Plain Text"

Red Underlines on Valid Code

// If Intelephense flags valid PHP 8.x syntax as errors
// Check your PHP version setting:
"intelephense.environment.phpVersion": "8.2.0"

// If it flags a valid extension function as undefined
// Make sure the extension stub is in your stubs list
// For example, if curl_init() is flagged:
"intelephense.stubs": ["curl", ...]

Vendor Directory Causing Slow Indexing

// Exclude vendor test directories to speed up indexing
"intelephense.files.exclude": [
    "**/vendor/**/{Tests,tests}/**",
    "**/vendor/**/Test/**",
    "**/vendor/**/spec/**"
]

// For very large vendor directories you can exclude vendor entirely
// but you'll lose autocompletion for Composer packages
"intelephense.files.exclude": [
    "**/vendor/**"
]

Duplicate Suggestions Appearing

# This means PHP Language Features is still enabled
# Go to Extensions → search "PHP Language Features"
# Make sure it shows "Disabled" not "Enabled"
# Reload VS Code window after disabling:
# Ctrl + Shift + P → "Developer: Reload Window"

Class Not Found / Undefined Type Errors on Valid Classes

# The file containing the class may not be indexed yet
# or the namespace doesn't match the directory structure

# Force re-index the workspace:
# Ctrl + Shift + P → "Intelephense: Index workspace"

# Check your composer.json autoload matches directory structure:
{
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    }
}

Free vs Premium

PHP Intelephense has a free tier and a paid licence. The free tier covers everything most developers need:

FeatureFreePremium
Code completion
Go to definition
Diagnostics
Hover documentation
Code formatting
Find all references
Rename symbol
Code actions
Type hierarchy

The premium licence is a one-time purchase. Enter a licence key by opening the command palette with Ctrl+Shift+P and searching for “Enter licence key”. If you use Find All References or Rename Symbol regularly, the premium features pay for themselves quickly on any real project.

Recommended VS Code Settings for PHP Projects

Complete settings file combining Intelephense configuration with other useful PHP development settings:

{
    // PHP Intelephense
    "intelephense.environment.phpVersion": "8.2.0",
    "intelephense.telemetry.enabled": false,
    "intelephense.completion.insertUseDeclaration": true,
    "intelephense.completion.triggerParameterHints": true,
    "intelephense.diagnostics.enable": true,
    "intelephense.files.exclude": [
        "**/.git/**",
        "**/node_modules/**",
        "**/vendor/**/{Tests,tests}/**",
        "**/storage/**",
        "**/bootstrap/cache/**"
    ],

    // Format PHP on save using Intelephense
    "[php]": {
        "editor.formatOnSave": true,
        "editor.defaultFormatter": "bmewburn.vscode-intelephense-client",
        "editor.tabSize": 4,
        "editor.insertSpaces": true
    },

    // Editor settings
    "editor.fontSize": 14,
    "editor.wordWrap": "on",
    "editor.renderWhitespace": "boundary",
    "editor.bracketPairColorization.enabled": true,
    "editor.guides.bracketPairs": true,

    // File settings
    "files.trimTrailingWhitespace": true,
    "files.insertFinalNewline": true,
    "files.eol": "\n",

    // Explorer
    "explorer.confirmDelete": false,
    "explorer.confirmDragAndDrop": false
}

Frequently Asked Questions

What is PHP Intelephense?

PHP Intelephense is a PHP language server extension for Visual Studio Code developed by Ben Mewburn. It provides intelligent code completion, real-time error detection, go-to definition, hover documentation, and formatting for PHP files. It uses the Language Server Protocol (LSP) to communicate with VS Code and runs a local analysis server that indexes your PHP project.

Is PHP Intelephense free?

The core features are free – code completion, go-to definition, diagnostics, hover documentation, and formatting. Premium features including Find All References, Rename Symbol, Code Actions, and Type Hierarchy require a paid licence. The free version covers everything needed for solo PHP development.

Why is Intelephense not working after installation?

The most common cause is that PHP Language Features – VS Code’s built-in PHP extension – is still enabled. It conflicts with Intelephense and causes duplicates or broken completions. Go to Extensions, search for “PHP Language Features”, and disable it. Then reload the VS Code window with Ctrl + Shift + P → “Developer: Reload Window”.

Does PHP Intelephense work with Laravel and Symfony?

Yes. Intelephense indexes your entire project including vendor packages pulled in by Composer. Laravel facades, Eloquent model methods, Symfony service container types – all get completion and type checking. For Laravel specifically, the Laravel Extra Intellisense extension complements Intelephense with route and view name completions that Intelephense doesn’t cover.

How do I speed up Intelephense on a large project?

Three things help significantly. First, exclude vendor test directories from indexing – they add thousands of files with no development benefit. Second, increase the file size limit if you have large generated files. Third, exclude cache and storage directories. The configuration examples in this guide cover all three. Indexing only happens once per workspace open – subsequent completions are fast regardless of project size.

Can I use PHP Intelephense with PhpStorm?

No. PHP Intelephense is a VS Code extension specifically built for the VS Code/LSP ecosystem. PhpStorm has its own built-in PHP intelligence that doesn’t use external language servers. If you’re already using PhpStorm you don’t need Intelephense – PhpStorm’s PHP support is comprehensive out of the box.


Summary

PHP Intelephense transforms VS Code into a capable PHP development environment. The setup is straightforward but the critical step of disabling PHP Language Features is what makes it actually work:

  • Install from the VS Code marketplace: bmewburn.vscode-intelephense-client
  • Disable PHP Language Features – keep PHP Language Basics enabled
  • Set the PHP version in settings to match your project
  • Add stubs for the PHP extensions your project uses
  • Enable format on save for automatic PHP-FIG formatting
  • Exclude vendor test directories to keep indexing fast

For the PHP development workflow that Intelephense supports, the PHP project setup guide covers folder structure, VS Code setup, and getting a new PHP project running from scratch. For version control of that project, the Git for PHP developers guide covers the complete setup and daily workflow.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top