What is Laravel LSP?
Laravel LSP (Language Server Protocol) is the official tool from Laravel that brings Framework-aware IDE features to your editor. The Language Server Protocol is a standard communication protocol between LSP clients (like your editor) and an LSP server (Laravel LSP), enabling a unified development experience across multiple editors.Features Provided by Laravel LSP
- Completions — Auto-complete for routes, views, configuration keys, translation keys, Livewire components, and more
- Hover Information — Display documentation and context information when hovering over code
- Diagnostics — Real-time detection of code issues and problems
- Document Links — Navigate between related files and resources
- Quick Fixes — Automatic suggestions to resolve common issues
- Definition Jumping — Navigate to symbol definitions
Why You Need It
Standard PHP editor completions can’t understand Laravel’s abstraction layers. For example:- Typing a URI pattern in
Route::get()gets no completion suggestions - Using
view('users.index')provides no completion for view file names - Configuration keys like
config('app.name')and translation keys liketrans('messages.welcome')aren’t recognized - Blade template completions and validation aren’t available in standard editors
Installation
Global Installation
Install globally using Composer:PATH, then start the server:
From Source
For development or using unreleased versions, clone and run from the repository:laravel-lsp from anywhere:
Editor Setup Guide
Laravel LSP uses the standard LSP protocol, so it works with any LSP-compatible editor. Here’s how to configure the most popular ones.Sublime Text
Install the LSP package, then add the client configuration inPreferences: LSP Settings:
Neovim
With Neovim 0.11+, add a custom LSP configuration:nvim-lspconfig:
Cursor
Cursor supports VS Code extensions, so if you have a Laravel extension installed, it should work automatically. For local development, use a VS Code-compatible LSP client and point it to:VS Code
VS Code has built-in LSP client support and can be configured similarly through extensions.OpenCode
Enable LSP support inopencode.json and add Laravel LSP as a custom server:
GitHub Copilot CLI Configuration
If you’re using GitHub Copilot CLI, you can configure Laravel LSP globally in~/.copilot/lsp-config.json without additional editor configuration:
initializationOptions, allowing you to use all the advanced options described below.
Configuration Options
LSP clients can pass detailed configuration to Laravel LSP throughinitializationOptions.
PHP Environment Detection
ThephpEnvironment option controls which PHP command is used when indexing project data. Default is auto for automatic detection:
| Value | PHP Command Behavior |
|---|---|
auto | Auto-detect in order: Herd → Valet → Sail → Lando → DDEV → local PHP |
herd | Use herd which-php |
valet | Use valet which-php |
sail | Use ./vendor/bin/sail php when Sail is running |
lando | Use lando php when available |
ddev | Use ddev php when available |
local | Use the local PHP binary directly |
php.
Basic Configuration Example
Per-Feature Configuration
Individual features can be enabled or disabled. Common suffixes areCompletion, Diagnostics, Hover, and Link:
Features by Area
| Area | Completion | Hover | Diagnostics | Links | Quick Fixes |
|---|---|---|---|---|---|
| Routes | ✓ | ✓ | ✓ | ✓ | - |
| Views & Blade | ✓ | ✓ | ✓ | ✓ | ✓ |
| Translations | ✓ | ✓ | - | - | - |
| Configuration | ✓ | ✓ | ✓ | ✓ | - |
| Environment Variables | ✓ | ✓ | ✓ | ✓ | ✓ |
| Assets & Mix | ✓ | ✓ | ✓ | ✓ | - |
| Middleware | ✓ | ✓ | ✓ | ✓ | - |
| Inertia | ✓ | - | ✓ | ✓ | - |
| Livewire Components | ✓ | ✓ | - | ✓ | - |
| Auth & Policies | ✓ | ✓ | ✓ | ✓ | - |
| Container Bindings | ✓ | ✓ | ✓ | ✓ | - |
| Validation Rules | ✓ | - | - | - | - |
| Controller Actions | ✓ | - | ✓ | ✓ | - |
| Eloquent | ✓ | - | - | - | - |
Quick Start
- Install — Run
composer global require laravel/lsp - Configure Your Editor — Follow the editor-specific guide above
- Open a Laravel Project — The server indexes routes, views, translations, configuration, and other project data from your project root
- Start Coding — Framework-aware completions and diagnostics activate automatically in PHP and Blade files
Summary
Laravel LSP significantly enhances your development experience by understanding Laravel’s Framework-specific contexts that standard editors can’t recognize. It provides intelligent completions, accurate diagnostics, and powerful navigation features tailored to Laravel development. Requirements:- PHP 8.2 or higher
- Composer
- LSP-compatible editor (Sublime Text, Neovim, Cursor, VS Code, etc.)