> ## Documentation Index
> Fetch the complete documentation index at: https://kawax.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# Laravel LSP — extending IDE features via the Language Server Protocol

> Laravel's official Language Server Protocol implementation. Adds framework-aware completion and hover features to your editor.

<Info>
  This article reflects v0.0.27, as of July 2026. Laravel LSP is now registered on Packagist and can be installed with `composer global require laravel/lsp`.
</Info>

## What is Laravel LSP?

**Laravel LSP** (Language Server Protocol) is Laravel's official tool that brings framework-aware IDE features to your editor. The [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) is a standard protocol for communication between an LSP client (your editor) and an LSP server (Laravel LSP), enabling a unified development experience across multiple editors.

Features provided by Laravel LSP:

* **Completion** — Auto-complete routes, views, config keys, translation keys, Livewire components, and more
* **Hover info** — Show descriptions, documentation, and context info when hovering
* **Diagnostics** — Detect issues in your code in real time
* **Document links** — Link between files and resources
* **Quick fixes** — Auto-fix suggestions for common issues
* **Go to definition** — Jump to a symbol's definition

## Why you need it

The editor's built-in PHP completion doesn't understand the Laravel framework's abstraction layers. For example:

* No completion for the URI pattern as the first argument of `Route::get()`
* Entering a view name in `view('users.index')` doesn't complete against actual view files
* Config keys (`config('app.name')`) and translation keys (`trans('messages.welcome')`) aren't included in completion
* Completion and validation inside Blade templates aren't supported by default

Laravel LSP understands these "framework-specific contexts" and provides accurate completion and diagnostics.

## Installation

### Global installation

Install globally with Composer:

```bash theme={null}
composer global require laravel/lsp
```

Make sure Composer's global bin directory is on your `PATH`. You can then start it with:

```bash theme={null}
laravel-lsp
```

### Installation from source

To use the development version, clone the repository and run it:

```bash theme={null}
gh repo clone laravel/lsp
cd lsp
composer install
php server
```

Set up a shell alias so you can use the `laravel-lsp` command:

```bash theme={null}
# For Zsh
echo 'alias laravel-lsp="php /path/to/lsp/server"' >> ~/.zshrc
source ~/.zshrc

# For Bash
echo 'alias laravel-lsp="php /path/to/lsp/server"' >> ~/.bashrc
source ~/.bashrc
```

## Editor configuration guides

Because Laravel LSP uses the standard LSP protocol, it works with any editor that supports LSP. Here are configurations for major editors.

### Sublime Text

Install and configure the official [Laravel Sublime Text extension](https://github.com/laravel/sublime-extension).

### Zed

Install and configure the official [Laravel Zed extension](https://github.com/laravel/zed-extension).

### VS Code

Install and configure the official [Laravel VS Code extension](https://github.com/laravel/vs-code-extension).

### Cursor

Cursor supports VS Code extensions, so the [Laravel VS Code extension](https://github.com/laravel/vs-code-extension) above works as-is.

### Neovim

On Neovim 0.11+, you can add a custom LSP configuration directly:

```lua theme={null}
vim.lsp.config("laravel_lsp", {
    cmd = { "laravel-lsp" },
    filetypes = { "php", "blade" },
    root_markers = { "artisan", "composer.json", ".git" },
})

vim.lsp.enable("laravel_lsp")
```

If you use `nvim-lspconfig`, register it like this:

```lua theme={null}
local lspconfig = require("lspconfig")
local configs = require("lspconfig.configs")

if not configs.laravel_lsp then
    configs.laravel_lsp = {
        default_config = {
            cmd = { "laravel-lsp" },
            filetypes = { "php", "blade" },
            root_dir = lspconfig.util.root_pattern("artisan", "composer.json", ".git"),
        },
    }
end

lspconfig.laravel_lsp.setup({})
```

### OpenCode

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

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

## Configuring with the GitHub Copilot CLI

When using the GitHub Copilot CLI, you can configure it globally in `~/.copilot/lsp-config.json`. No separate editor configuration is required:

```json theme={null}
{
  "lspServers": {
    "laravel-lsp": {
      "command": "laravel-lsp",
      "fileExtensions": {
        ".php": "php",
        ".blade.php": "blade"
      }
    }
  }
}
```

Copilot CLI's LSP server configuration also supports `initializationOptions`, so you can use all the detailed settings described below.

## Configuration options

LSP clients can pass detailed configuration to Laravel LSP through `initializationOptions`.

### PHP environment detection

The `phpEnvironment` option controls the PHP command used to index project data. The default is `auto`, which auto-detects:

| Value   | PHP command behavior                                        |
| ------- | ----------------------------------------------------------- |
| `auto`  | Try Herd → Valet → Sail → Lando → DDEV → local PHP in order |
| `herd`  | Uses `herd which-php`                                       |
| `valet` | Uses `valet which-php`                                      |
| `sail`  | Uses `./vendor/bin/sail php` while Sail is running          |
| `lando` | Uses `lando php`                                            |
| `ddev`  | Uses `ddev php`                                             |
| `local` | Uses the local PHP binary directly                          |

If detection fails or an invalid value is passed, it falls back to `php`.

### Basic configuration example

```json theme={null}
{
    "phpEnvironment": "auto",
    "phpCommand": ["php"],
    "definitionProvider": false
}
```

### Pest helper docblocks

Added in v0.0.27. Generates and keeps Pest helper docblocks up to date whenever tests or Composer autoload files change:

| Option                  | Type      | Default                                 | Description                                                        |
| ----------------------- | --------- | --------------------------------------- | ------------------------------------------------------------------ |
| `pestGenerateDocBlocks` | `boolean` | `true`                                  | Whether to generate and keep Pest helper docblocks updated         |
| `pestHelperFilePath`    | `string`  | `"storage/framework/testing/_pest.php"` | Output path for the Pest helper file, relative to the project root |

```json theme={null}
{
    "pestGenerateDocBlocks": true,
    "pestHelperFilePath": "storage/framework/testing/_pest.php"
}
```

### Per-feature configuration

Each feature can be individually enabled or disabled. Suffixes include `Completion`, `Diagnostics`, `Hover`, `Link`, and so on:

```json theme={null}
{
    "routeCompletion": true,
    "routeDiagnostics": true,
    "viewDiagnostics": false,
    "translationHover": true,
    "configLink": true,
    "envCompletion": true,
    "bladeComponentLink": true
}
```

## Provided features overview

| Feature area       | Completion | Hover | Diagnostics | Link | Quick fixes |
| ------------------ | ---------- | ----- | ----------- | ---- | ----------- |
| Routes             | ✓          | ✓     | ✓           | ✓    | -           |
| Views & Blade      | ✓          | ✓     | ✓           | ✓    | ✓           |
| Translation        | ✓          | ✓     | -           | -    | -           |
| Config             | ✓          | ✓     | ✓           | ✓    | -           |
| Env variables      | ✓          | ✓     | ✓           | ✓    | ✓           |
| Assets & Mix       | ✓          | ✓     | ✓           | ✓    | -           |
| Middleware         | ✓          | ✓     | ✓           | ✓    | -           |
| Inertia            | ✓          | -     | ✓           | ✓    | -           |
| Livewire           | ✓          | ✓     | -           | ✓    | -           |
| Auth & Policies    | ✓          | ✓     | ✓           | ✓    | -           |
| Container Bindings | ✓          | ✓     | ✓           | ✓    | -           |
| Validation         | ✓          | -     | -           | -    | -           |
| Controller Actions | ✓          | -     | ✓           | ✓    | -           |
| Eloquent           | ✓          | -     | -           | -    | -           |

## Quick start

1. **Install** — `composer global require laravel/lsp`
2. **Configure your editor** — see the per-editor guides above
3. **Open a Laravel project** — the server indexes project data from the root: routes, views, translations, config, etc.
4. **Use completion** — framework-aware completion works automatically inside PHP files and Blade templates

## Summary

Laravel LSP significantly improves the developer experience. It understands framework-specific context that the editor's default features can't, and delivers more accurate and useful completion and diagnostics.

**Requirements:**

* PHP 8.2 or later
* Composer
* An LSP-capable editor (Sublime Text, Neovim, Cursor, VS Code, etc.)

**References:**

* [Laravel LSP GitHub repository](https://github.com/laravel/lsp)
* [Language Server Protocol official site](https://microsoft.github.io/language-server-protocol/)
* [GitHub Copilot CLI LSP setup guide](https://docs.github.com/en/copilot/how-tos/copilot-cli/set-up-copilot-cli/add-lsp-servers)


## Related topics

- [Identity](/en/packages/laravel-bluesky/identity.md)
- [Laravel Boost](/en/boost.md)
- [Laravel Octane](/en/octane.md)
- [Laravel 13 new features overview](/en/blog/laravel-13-new-features.md)
- [Laravel Passkeys initial research (passkeys-server + @laravel/passkeys)](/en/blog/passkeys-introduction.md)
