## Installation ### Visual Studio Code Visual Studio Code users should install the Intelephense extension from within the extensions view or download from the [marketplace](https://marketplace.visualstudio.com/items?itemName=bmewburn.vscode-intelephense-client). 1. Disable the built-in VSCode PHP Language Features. * Go to `Extensions`. * Search for `@builtin php` * Disable `PHP Language Features`. Leave `PHP Language Basics` enabled for syntax highlighting. Note that other (3rd party) PHP extensions which provide similar functionality should also be disabled for best results. 2. Add glob patterns for non standard php file extensions to the `files.associations` setting. For example: `"files.associations": { "*.module": "php" }`. 3. Optionally purchase and enter your [licence key](https://intelephense.com) by opening the command pallete -- `ctrl + shift + p` -- and searching for `Enter licence key`. Further configuration options are available in the `intelephense` section of settings. ### Other Editors #### Requirements [Node.js 12+](https://nodejs.org) #### Server Installation ``` npm i intelephense -g ``` #### Language Server Protocol (LSP) Client Intelephense needs an LSP compliant client to communicate with and integrate features into the editor. A list of editors and clients that support the LSP can be found at https://microsoft.github.io/language-server-protocol/implementors/tools/. Please follow the setup guide of the relevant tool. The Information below may help in configuring the client. #### Run ``` intelephense {transport} ``` Where `{transport}` is one of: * `--node-ipc` * `--stdio` * `--socket={number}` * `--pipe={string}` #### Initialisation Options ```typescript interface InitialisationOptions { //Optional absolute path to storage dir. Defaults to os.tmpdir(). storagePath?: string; //Optional absolute path to a global storage dir. Defaults to os.homedir(). globalStoragePath?: string; //Optional licence key or absolute path to a text file containing the licence key. //{os.homedir()}/intelephense/licence.txt will also be checked by //default if initializationOptions are not exposed by client. licenceKey?: string; //Optional flag to clear server state. //State can also be cleared by deleting {storagePath}/intelephense clearCache?: boolean; } ``` #### Capabilities
Server capabilities JSON returned from `initialize` request. ```javascript { textDocumentSync: TextDocumentSyncKind.Incremental, documentSymbolProvider: true, workspaceSymbolProvider: true, completionProvider: { triggerCharacters: [ //php '$', '>', ':', '\\', '/', //phpdoc '*', // html/js '.', '<' ], resolveProvider: true }, signatureHelpProvider: { triggerCharacters: ['(', ','] }, definitionProvider: true, referencesProvider: true, hoverProvider: true, documentFormattingProvider: true, //Dynamic registration if available. documentRangeFormattingProvider: true, //Dynamic registration if available. documentHighlightProvider: true, workspace: { workspaceFolders: { supported: true, changeNotifications: true } }, foldingRangeProvider: true, //With licence key only. implementationProvider: true, //With licence key only. declarationProvider: true, //With licence key only. renameProvider: { //With licence key only. prepareProvider: true }, typeDefinitionProvider: true, //With licence key only. selectionRangeProvider: true //With licence key only. } ```
#### Configuration Options
JSON schema for `workspace/configuration` request data ```json { "intelephense.compatibility.correctForBaseClassStaticUnionTypes": { "type": "boolean", "default": true, "description": "Resolves `BaseClass|static` union types to `static` instead of `BaseClass`.", "scope": "window" }, "intelephense.compatibility.correctForArrayAccessArrayAndTraversableArrayUnionTypes": { "type": "boolean", "default": true, "description": "Resolves `ArrayAccess` and `Traversable` implementations that are unioned with a typed array to generic syntax. eg `ArrayAccessOrTraversable|ElementType[]` => `ArrayAccessOrTraversable`.", "scope": "window" }, "intelephense.files.maxSize": { "type": "number", "default": 1000000, "description": "Maximum file size in bytes.", "scope": "window" }, "intelephense.files.associations": { "type": "array", "default": [ "*.php", "*.phtml" ], "description": "Configure glob patterns to make files available for language server features. Inherits from files.associations.", "scope": "window" }, "intelephense.files.exclude": { "type": "array", "items": { "type": "string" }, "default": [ "**/.git/**", "**/.svn/**", "**/.hg/**", "**/CVS/**", "**/.DS_Store/**", "**/node_modules/**", "**/bower_components/**", "**/vendor/**/{Tests,tests}/**", "**/.history/**", "**/vendor/**/vendor/**" ], "description": "Configure glob patterns to exclude certain files and folders from all language server features. Inherits from files.exclude.", "scope": "resource" }, "intelephense.stubs": { "type": "array", "items": { "type": "string", "enum": [ "amqp", "apache", "apcu", "bcmath", "blackfire", "bz2", "calendar", "cassandra", "com_dotnet", "Core", "couchbase", "crypto", "ctype", "cubrid", "curl", "date", "dba", "decimal", "dom", "ds", "enchant", "Ev", "event", "exif", "fann", "FFI", "ffmpeg", "fileinfo", "filter", "fpm", "ftp", "gd", "gearman", "geoip", "geos", "gettext", "gmagick", "gmp", "gnupg", "grpc", "hash", "http", "ibm_db2", "iconv", "igbinary", "imagick", "imap", "inotify", "interbase", "intl", "json", "judy", "ldap", "leveldb", "libevent", "libsodium", "libxml", "lua", "lzf", "mailparse", "mapscript", "mbstring", "mcrypt", "memcache", "memcached", "meminfo", "meta", "ming", "mongo", "mongodb", "mosquitto-php", "mqseries", "msgpack", "mssql", "mysql", "mysql_xdevapi", "mysqli", "ncurses", "newrelic", "oauth", "oci8", "odbc", "openssl", "parallel", "Parle", "pcntl", "pcov", "pcre", "pdflib", "PDO", "pdo_ibm", "pdo_mysql", "pdo_pgsql", "pdo_sqlite", "pgsql", "Phar", "phpdbg", "posix", "pspell", "pthreads", "radius", "rar", "rdkafka", "readline", "recode", "redis", "Reflection", "regex", "rpminfo", "rrd", "SaxonC", "session", "shmop", "SimpleXML", "snmp", "soap", "sockets", "sodium", "solr", "SPL", "SplType", "SQLite", "sqlite3", "sqlsrv", "ssh2", "standard", "stats", "stomp", "suhosin", "superglobals", "svn", "sybase", "sync", "sysvmsg", "sysvsem", "sysvshm", "tidy", "tokenizer", "uopz", "uv", "v8js", "wddx", "win32service", "winbinder", "wincache", "wordpress", "xcache", "xdebug", "xhprof", "xml", "xmlreader", "xmlrpc", "xmlwriter", "xsl", "xxtea", "yaf", "yaml", "yar", "zend", "Zend OPcache", "ZendCache", "ZendDebugger", "ZendUtils", "zip", "zlib", "zmq", "zookeeper" ] }, "default": [ "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", "readline", "Reflection", "session", "shmop", "SimpleXML", "snmp", "soap", "sockets", "sodium", "SPL", "sqlite3", "standard", "superglobals", "sysvmsg", "sysvsem", "sysvshm", "tidy", "tokenizer", "xml", "xmlreader", "xmlrpc", "xmlwriter", "xsl", "Zend OPcache", "zip", "zlib" ], "description": "Configure stub files for built in symbols and common extensions. The default setting includes PHP core and all bundled extensions.", "scope": "window" }, "intelephense.completion.insertUseDeclaration": { "type": "boolean", "default": true, "description": "Use declarations will be automatically inserted for namespaced classes, traits, interfaces, functions, and constants.", "scope": "window" }, "intelephense.completion.fullyQualifyGlobalConstantsAndFunctions": { "type": "boolean", "default": false, "description": "Global namespace constants and functions will be fully qualified (prefixed with a backslash).", "scope": "window" }, "intelephense.completion.triggerParameterHints": { "type": "boolean", "default": true, "description": "Method and function completions will include parentheses and trigger parameter hints.", "scope": "window" }, "intelephense.completion.maxItems": { "type": "number", "default": 100, "description": "The maximum number of completion items returned per request.", "scope": "window" }, "intelephense.format.enable": { "type": "boolean", "default": true, "description": "Enables formatting.", "scope": "window" }, "intelephense.format.braces": { "type": "string", "default": "psr12", "enum": [ "psr12", "allman", "k&r" ], "enumDescriptions": [ "PHP-FIG PSR-2 and PSR-12 style. A mix of Allman and K&R", "Allman. Opening brace on the next line.", "K&R (1TBS). Opening brace on the same line." ], "description": "Controls formatting style of braces", "scope": "window" }, "intelephense.environment.documentRoot": { "type": "string", "description": "The directory of the entry point to the application (index.php). Defaults to the first workspace folder. Used for resolving script inclusion.", "scope": "window" }, "intelephense.environment.includePaths": { "type": "array", "items": { "type": "string" }, "description": "The include paths (as individual path items) as defined in the include_path ini setting. Used for resolving script inclusion.", "scope": "window" }, "intelephense.environment.phpVersion": { "type": "string", "default": "7.4.0", "description": "A semver compatible string that represents the target PHP version. Used for providing version appropriate suggestions and diagnostics. PHP 5.3.0 and greater supported.", "scope": "window" }, "intelephense.environment.shortOpenTag": { "type": "boolean", "default": false, "description": "When enabled '