Registry / devops / intelephense

intelephense

JSON →
library1.16.5jsnpmunverified

Intelephense is a high-performance PHP language server that provides robust IDE features such as code completion, parameter hints, diagnostics, formatting, and symbol navigation. It supports PHP 7 and 8, offering comprehensive static analysis and accurate type inference for modern PHP projects. While widely recognized as a VS Code extension, the `intelephense` npm package specifically distributes the command-line interface (CLI) of the language server. This CLI enables integration with various Language Server Protocol (LSP) clients beyond VS Code or facilitates its use in automated workflows like CI/CD pipelines for linting and diagnostics. Currently at version 1.16.5 on npm, the project is actively developed, ensuring regular updates to support new PHP features and maintain compatibility with evolving editor integrations. Its primary differentiators include its speed, detailed static analysis tailored for PHP, and a rich feature set that significantly enhances PHP development experience.

npm install intelephense
INSTALL
IMPORT
SIG · INTELEPHENSE
I
intelephense
devopsjavascriptv1.16.5
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

runIntelephense
import { spawn } from 'node:child_process'; const intelephenseProcess = spawn('intelephense', ['--version'], { stdio: 'inherit' });
import { intelephense } from 'intelephense';
Intelephense is primarily a CLI tool and does not export JavaScript/TypeScript modules for direct import. Its functionality is accessed by spawning its executable.
runDiagnostics
import { exec } from 'node:child_process'; exec('intelephense diagnostics /path/to/project --json', (error, stdout, stderr) => { if (error) console.error(`Error: ${error.message}`); console.log(stdout); });
intelephense.diagnostics('/path/to/project');
To integrate Intelephense diagnostics into a Node.js workflow, execute the `diagnostics` command via `child_process.exec` or `spawn`. Use `--json` for programmatic output.
resolveExecutablePath
import { resolve } from 'node:path'; import { existsSync } from 'node:fs'; const intelephenseBin = resolve(process.cwd(), 'node_modules', '.bin', 'intelephense'); if (existsSync(intelephenseBin)) console.log(`Intelephense executable found at: ${intelephenseBin}`);
import { getPath } from 'intelephense';
When installed via npm, the `intelephense` executable is typically located in the `node_modules/.bin/` directory relative to your project root.

This quickstart demonstrates how to install Intelephense locally, create a sample PHP file, and then programmatically run diagnostics on it using Node.js's `child_process` module to capture and parse the output.

import { execSync } from 'node:child_process'; import { writeFileSync, existsSync, mkdirSync } from 'node:fs'; import { join } from 'node:path'; const projectRoot = './tmp_php_project'; const phpFilePath = join(projectRoot, 'index.php'); if (!existsSync(projectRoot)) { mkdirSync(projectRoot); } // Create a sample PHP file for diagnostics const phpContent = `<?php class MyClass { public function greet(string $name): string { return 'Hello, ' . $name; } } $obj = new MyClass(); // Missing semicolon here intentionally for diagnostics echo $obj->greet('World') // Undefined variable to demonstrate diagnostics $undefinedVar = $nonExistentVar; `; writeFileSync(phpFilePath, phpContent); console.log('Running Intelephense diagnostics on the sample PHP file...'); try { // Run diagnostics and capture output const output = execSync(`intelephense diagnostics ${projectRoot} --json`, { encoding: 'utf8' }); const diagnostics = JSON.parse(output); console.log('Intelephense Diagnostics Report:'); if (diagnostics.length > 0) { diagnostics.forEach(diag => { console.log(`- [${diag.severity}] ${diag.message} at ${diag.uri}:${diag.range.start.line + 1}:${diag.range.start.character + 1}`); }); } else { console.log('No diagnostics reported (might indicate no issues or configuration problem).'); } } catch (error) { console.error('Failed to run Intelephense diagnostics:', error.message); if (error.stderr) console.error(error.stderr); console.error('Make sure PHP is installed and in your PATH, and intelephense is installed via `npm i -g intelephense` or `npm i intelephense`.'); } // Clean up (optional) // require('node:fs').rmSync(projectRoot, { recursive: true, force: true });
intelephense --version
Debug
Known issues
gotchaThe full feature set of Intelephense (including certain advanced diagnostics, refactoring, and other premium LSP capabilities) requires a paid license. While basic functionality is available, premium features will be locked without a valid license, even when using the CLI.
fix
Purchase a premium license from the official Intelephense website (intelephense.com) and configure it in your editor or via the server's configuration files if applicable.
affects: >=1.0.0
gotchaIntelephense requires a PHP executable to be installed and accessible in your system's PATH. If PHP is not found or the version is incompatible, the server will fail to start or provide accurate diagnostics.
fix
Ensure PHP (version 7 or higher) is installed on your system and its executable directory is included in your system's PATH environment variable. Verify by running `php -v` in your terminal.
affects: >=1.0.0
gotchaPerformance issues or incorrect diagnostics can sometimes stem from missing or misconfigured PHP stub files (`intelephense.stubs`) or an incorrect `intelephense.storagePath` pointing to a non-writable directory.
fix
Check the Intelephense documentation for recommended stub configurations and ensure the `storagePath` is set to a writable directory for caching and indexing. For VS Code users, these are typically configured in `settings.json`.
affects: >=1.0.0
breakingPrior to version 1.0, some configuration options and command-line arguments might have differed. While the core LSP functionality remained, direct CLI usage and specific settings could require adjustments.
fix
It is highly recommended to use Intelephense versions 1.0 or higher for stability and modern PHP support. Consult the changelog for specific migration steps if upgrading from pre-1.0 versions.
affects: <1.0.0
Errors
Common errors & fixes
command not found: intelephense
The Intelephense CLI executable is not in your system's PATH.
fix
If installed globally (`npm i -g intelephense`), ensure npm's global bin directory is in your PATH. If installed locally, run `npx intelephense` or add `node_modules/.bin` to your PATH for script execution.
No PHP executable found. Please install PHP and add it to your PATH.
Intelephense could not locate a PHP executable on the system.
fix
Install PHP (version 7 or later) and verify it's added to your system's PATH. You can test by running `php -v` in your terminal.
Error: EACCES: permission denied, open '/path/to/.intelephense/somefile'
Intelephense attempts to write to a directory for caching or indexing but lacks the necessary file system permissions.
fix
Ensure the directory specified by `intelephense.storagePath` (or the default storage location) has write permissions for the user running Intelephense. You might need to change directory permissions or specify a different storage path.
Diagnostics for PHP files are inaccurate or not appearing.
This can be due to an outdated PHP version, incorrect `intelephense.stubs` configuration, or issues with PHP extensions.
fix
Verify your `intelephense.stubs` setting includes all necessary PHP extensions you are using (e.g., `['php', 'json', 'pcre', 'standard', 'wordpress']`). Ensure your PHP installation and extensions are up-to-date and correctly configured.
Upgrade
Version history
1.16.5latest on npm
Audit
Dependencies
PHPrequiredIntelephense is a PHP language server and requires a PHP executable (version 7 or later) to function correctly for analysis.
Agent activity
4 hits · last 30 days
node
4
Resources