README.md

September 7, 2026 · View on GitHub

Introduction

Laravel LSP provides framework-aware editor features for Laravel applications, including completions, hover information, diagnostics, document links, Go to Definition, and code actions for Laravel and Blade code.

Installation

Install Laravel LSP globally with Composer:

composer global require laravel/lsp

Ensure Composer's global bin directory is on your PATH.

Editor Usage

The server communicates over stdio. Configure your editor to launch it from the Laravel project root whenever possible.

Sublime Text

Install and configure the official Laravel Sublime Text extension.

Zed

Install and configure the official Laravel Zed extension.

VS Code

Install and configure the official Laravel VS Code extension.

Cursor

Install and configure the official Laravel VS Code extension, which is compatible with Cursor.

Neovim

Neovim 0.11+ is required. Add a custom LSP configuration:

vim.lsp.config("laravel_lsp", {
    cmd = { "laravel-lsp" },
    filetypes = { "php", "blade" },
    root_dir = function(bufnr, on_dir)
        local root = vim.fs.root(bufnr, "artisan")

        if root then
            on_dir(root)
        end
    end,
})

vim.lsp.enable("laravel_lsp")

The root_dir callback only starts the server when an artisan file is found, so the server is not launched for PHP projects that are not Laravel applications.

OpenCode

Enable LSP support in opencode.json and add Laravel LSP as a custom server:

{
    "$schema": "https://opencode.ai/config.json",
    "lsp": {
        "laravel-lsp": {
            "command": ["laravel-lsp"],
            "extensions": [".php", ".blade.php"]
        }
    }
}

Features

AreaCapabilities
RoutesCompletions, hovers, diagnostics, document links
Views and BladeCompletions, hovers, diagnostics, document links, code actions
TranslationsKey, locale, and parameter completions; hovers
ConfigKey completions, hovers, diagnostics, document links
Environment variablesCompletions, hovers, diagnostics, document links, code actions
Assets and MixCompletions, hovers, diagnostics, document links
MiddlewareCompletions, hovers, diagnostics, document links
InertiaPage and property completions, diagnostics, document links, code actions
Livewire componentsCompletions, hovers, document links
Auth and policiesCompletions, hovers, diagnostics, document links
Container bindingsCompletions, hovers, diagnostics, document links
Validation rulesCompletions
Controller actionsCompletions, diagnostics, document links
EloquentCompletions

Configuration

Editor clients pass configuration through the LSP initializationOptions object. All options are optional.

Server Options

OptionTypeDefaultDescription
phpEnvironmentstring"auto"Select the environment used to detect the PHP command for indexing project data.
phpCommandstring[]Detected from phpEnvironmentUse an explicit command and arguments, such as ["php"] or ["./vendor/bin/sail", "php"].
memoryLimitstring"512M"Set the LSP server process memory_limit during initialize. Use PHP shorthand such as "512M", "1G", or "-1".
definitionProviderbooleantrueAdvertise definition support to the editor. Definitions are resolved from enabled document link options.
pestGenerateDocBlocksbooleantrueGenerate Pest helper docblocks and keep them updated when tests or Composer autoload files change.
pestHelperFilePathstring"storage/framework/testing/_pest.php"Set the Pest helper output path relative to the Laravel project root.

The phpEnvironment option controls which PHP command is used when the server runs project data scripts. It accepts these values:

ValuePHP command behavior
autoTry Herd, Valet, Sail, Lando, DDEV, then local PHP
herdUse herd which-php
valetUse valet which-php
sailUse ./vendor/bin/sail php when Sail is running
landoUse lando php when available
ddevUse ddev php when available
localUse the local PHP binary resolved from php -r 'echo PHP_BINARY;'

If detection fails, or an unknown value is provided, the server falls back to php.

When phpCommand is a non-empty array, it takes precedence over phpEnvironment.

The memoryLimit option is applied to the LSP server process during initialize, before project index JSON is decoded. Official editor binaries otherwise default to PHP's 128M memory_limit. Invalid values fall back to "512M". This option does not change the PHP command used to run project scripts.

Feature Options

Every feature option is a boolean that defaults to true. Set an option to false to disable the corresponding capability.

FeatureCompletionDiagnosticsHoverDocument linksCode actions
Application bindingsappBindingCompletionappBindingDiagnosticsappBindingHoverappBindingLink
AssetsassetCompletionassetDiagnosticsassetLink
AuthorizationauthCompletionauthDiagnosticsauthHoverauthLink
Blade componentsbladeComponentCompletionbladeComponentHoverbladeComponentLink
ConfigconfigCompletionconfigDiagnosticsconfigHoverconfigLink
Controller actionscontrollerActionCompletioncontrollerActionDiagnosticscontrollerActionLink
Environment variablesenvCompletionenvDiagnosticsenvHoverenvLinkenvViteQuickFix
InertiainertiaCompletioninertiaDiagnosticsinertiaHoverinertiaLink
Livewire componentslivewireComponentCompletionlivewireComponentHoverlivewireComponentLink
MiddlewaremiddlewareCompletionmiddlewareDiagnosticsmiddlewareHovermiddlewareLink
Mix assetsmixCompletionmixDiagnosticsmixHovermixLink
Path helperspathsLink
RoutesrouteCompletionrouteDiagnosticsrouteHoverrouteLink
Storage disksstorageCompletionstorageDiagnosticsstorageLink
TranslationstranslationCompletiontranslationDiagnosticstranslationHovertranslationLink
ViewsviewCompletionviewDiagnosticsviewHoverviewLink

Supported Platforms

The following platforms are supported:

  • macOS arm64 and x64
  • Linux arm64 and x64
  • Windows x64

Contributing

Thank you for considering contributing to Laravel LSP! The contribution guide can be found in the Laravel documentation.

Code of Conduct

To help keep the Laravel community welcoming to all, please review and follow the Code of Conduct.

Security Vulnerabilities

See our security policy for information on reporting security vulnerabilities.

License

Laravel LSP is open-source software licensed under the MIT license.