Skip to content

PHP Tools for Sublime Text#

PHP Tools for Sublime Text is provided as a language server (LSP).

Requirements#

Installation#

Install PHP Tools Language Server as a NPM global tool:

npm i devsense-php-ls -g

Open Sublime Text and make sure you have installed Package Control and LSP package:

  • Tools / Command Palette: Install Package Control

command palette - install package control

  • Tools / Command Palette: Package Control: Install Package

install package

  • Search for LSP:

LSP

  • You'll see a confirmation in the status bar:

LSP installed

Enable PHP Tools Language Server#

Go to Preferences / Package Settings / LSP / Server Configurations

Server Config Menu

In the newly opened file LanguageServers.sublime-settings, add the following configuration:

{
    "phptools":
    {
        "enabled": true,
        "command": ["devsense-php-ls"],
        "selector": "embedding.php",
        "priority_selector": "source.php",
        "initialization_options" : {
            "0": "<YOUR_LICENSE_KEY>",
            "php.stubs": "*",
            "php.version": "8.5",
            "phpTools.language": "en",
            "php.completion.parameters": "parameters",
            "php.format.codeStyle": "psr-12"
        }
    }
}

Note, "initialization_options" are optional.

Registration#

Add <YOUR_LICENSE_KEY> in the "initialization_options" above to enable additional premium features including code actions and starred suggestions.

License key can be purchased on the purchase page.

Updating#

To update the language server, update the NPM global tool devsense-php-ls using the command below:

npm update devsense-php-ls -g