Skip to content

Latest commit

 

History

History
314 lines (248 loc) · 8.31 KB

File metadata and controls

314 lines (248 loc) · 8.31 KB

Sublime Text setup for Laravel + Inertia/Vue

The complete guide for developers who want speed and simplicity

Why Sublime for Laravel development?

  • It's FAST — Opens instantly, searches instantly, no indexing
  • You already know it — No learning curve if you've used it before
  • It's predictable — No surprises, no "smart" features fighting you
  • It's proven — 15+ years of stability

Installation checklist

1. Install Sublime Text and Package Control

  • Download Sublime Text 4 from sublimetext.com
  • Install Package Control: Cmd+Shift+P → "Install Package Control"
  • Restart Sublime

2. Essential packages for PHP/Laravel

Install via Cmd+Shift+P → "Package Control: Install Package":

  • LSP — The foundation for language intelligence
  • LSP-intelephense — PHP intelligence (go to definition, errors, etc.)
  • PHP Companion — Import classes, expand namespaces
  • Laravel Blade Highlighter — Blade syntax highlighting
  • DotENV — .env file syntax highlighting
  • SublimeLinter — Framework for linting
  • SublimeLinter-php — PHP syntax checking

3. Essential packages for Vue/Inertia

  • Vue Syntax Highlight — Vue SFC support
  • LSP-volar — Vue language server (intelligence for Vue files)
  • LSP-typescript — If using TypeScript
  • LSP-tailwindcss — Tailwind class completions (optional)
  • Emmet — HTML/CSS expansion (div.container → <div class="container">)

4. Code formatting

  • JsPrettier — Format JS/Vue/CSS files
  • PHP CS Fixer — Format PHP files (or use Pint via build system)

5. Quality of life packages

  • AdvancedNewFile — Create files with Cmd+Alt+N without touching mouse
  • SideBarEnhancements — Right-click menu improvements
  • GitGutter — See git changes in gutter (optional - can be distracting)
  • FileIcons — Better file icons in sidebar

Configuration

1. Base Sublime settings

Cmd+, to open preferences:

{
    "font_size": 14,
    "tab_size": 4,
    "translate_tabs_to_spaces": false,  // Keep tabs as tabs!
    "detect_indentation": false,  // Don't auto-detect, use our settings
    "rulers": [80, 120],
    "ensure_newline_at_eof_on_save": true,
    "trim_trailing_white_space_on_save": true,
    "folder_exclude_patterns": [
        ".git",
        "node_modules",
        "vendor",
        ".idea",
        ".vscode"
    ],
    "file_exclude_patterns": [
        "*.pyc",
        ".DS_Store",
        "*.min.js",
        "*.min.css"
    ],
    "index_exclude_patterns": [
        "*.log",
        "node_modules/*",
        "vendor/*",
        "storage/framework/*"
    ]
}

2. LSP settings

Cmd+Shift+P → "Preferences: LSP Settings":

{
    "clients": {
        "LSP-intelephense": {
            "enabled": true,
            "settings": {
                "intelephense.files.exclude": [
                    "**/.git/**",
                    "**/.svn/**",
                    "**/node_modules/**",
                    "**/vendor/**"
                ]
            }
        }
    }
}

3. Key bindings for Laravel workflow

Sublime Text → Settings → Key Bindings:

[
    // Import PHP class
    { "keys": ["alt+enter"], "command": "php_companion_import_class" },
    
    // Format file
    { "keys": ["cmd+shift+f"], "command": "js_prettier" },
    
    // Quick file creation
    { "keys": ["cmd+alt+n"], "command": "advanced_new_file_new" },
    
    // Multiple cursors (already default, but good to know)
    { "keys": ["cmd+d"], "command": "find_under_expand" },
    { "keys": ["cmd+shift+l"], "command": "split_selection_into_lines" }
]

4. Setting up Pint (Laravel's PHP formatter)

First, make sure Pint is in your Laravel project:

# Pint comes with Laravel 9+, but check if it's there:
ls vendor/bin/pint

# If missing, install it:
composer require laravel/pint --dev

Configure Pint for tabs (important for your team):

Create pint.json in project root:

{
    "preset": "laravel",
    "rules": {
        "indentation_type": "tab",  // Use real tabs!
        "array_indentation": true,
        "array_syntax": {
            "syntax": "short"
        },
        "blank_line_before_statement": {
            "statements": ["return"]
        },
        "concat_space": {
            "spacing": "one"
        }
    }
}

Create Sublime build system:

Tools → Build System → New Build System:

{
    "name": "Laravel",
    "shell_cmd": "php artisan $file_name",
    "working_dir": "${project_path}",
    "variants": [
        {
            "name": "Pint - Current File",
            "shell_cmd": "./vendor/bin/pint $file"
        },
        {
            "name": "Pint - Entire Project",
            "shell_cmd": "./vendor/bin/pint"
        },
        {
            "name": "Pint - Test Run (Dry)",
            "shell_cmd": "./vendor/bin/pint --test"
        },
        {
            "name": "PHPUnit",
            "shell_cmd": "./vendor/bin/phpunit"
        },
        {
            "name": "Pest",
            "shell_cmd": "./vendor/bin/pest"
        }
    ]
}

Save as Laravel.sublime-build.

How to use:

  1. Edit a PHP file
  2. Cmd+Shift+B → Choose "Pint - Current File"
  3. File is formatted instantly
  4. Or use Cmd+B after selecting once

The complete workflow

For PHP/Laravel files

  1. Navigate to class: Cmd+Click or F12 (via Intelephense)
  2. Import class: Put cursor on class name, hit Alt+Enter
  3. Format: Cmd+Shift+B → "Pint Format"
  4. Find usages: Right-click → "LSP" → "Find References"

For Vue files

  1. Component navigation: Cmd+P and fuzzy search
  2. Props/emits intelligence: Via Volar
  3. Format: Cmd+Shift+F (JsPrettier)
  4. Emmet: Type div.container + Tab

For everything

  1. File search: Cmd+P — instant, no indexing
  2. Project search: Cmd+Shift+F — excludes vendor/node_modules
  3. Multi-cursor: Cmd+D to select next, Cmd+U to undo
  4. Command palette: Cmd+Shift+P for everything else

What's missing vs PHPStorm?

  • Xdebug integration — Use Ray or dd() instead
  • Database browser — Use TablePlus
  • Refactoring — Do it manually (makes you think about it)
  • Laravel-specific magic — You'll need to know your code structure

Common issues and fixes

Intelephense licensing (important!)

Free version includes:

  • Go to definition
  • Find references
  • Hover information
  • Basic completion
  • Signature help
  • Document symbols

Premium version ($20 lifetime) adds:

  • Rename (refactoring)
  • Code actions (auto-import, etc.)
  • Better type inference
  • Premium support

Can the license be used with Zed?

  • YES! One license works everywhere
  • Same license key works in Sublime, VSCode, Zed, Neovim, any editor with LSP
  • It's tied to YOU, not the editor
  • Best $20 you'll spend if doing PHP

How to buy and activate:

  1. Go to intelephense.com
  2. Buy license (one-time $20)
  3. Add to Sublime LSP settings:
{
    "clients": {
        "LSP-intelephense": {
            "settings": {
                "intelephense.licenceKey": "YOUR_KEY_HERE"
            }
        }
    }
}
  1. Later in Zed, add same key to its settings
  2. Works in both simultaneously!

LSP not working

  1. Check if language servers are installed:
    • npm install -g intelephense
    • npm install -g @volar/vue-language-server
  2. Restart Sublime after installing LSP packages
  3. Check LSP status: Cmd+Shift+P → "LSP: Show Diagnostics Panel"

Prettier not formatting PHP

  • Prettier doesn't format PHP
  • Use Pint (Laravel's formatter) via build system
  • Or install PHP CS Fixer package

Vue files not recognized

  • Make sure Vue Syntax Highlight is installed
  • Sometimes need to manually set syntax: Cmd+Shift+P → "Set Syntax: Vue"

The verdict

This setup gives you:

  • ✅ Fast file navigation
  • ✅ Basic code intelligence
  • ✅ Proper syntax highlighting
  • ✅ Code formatting
  • ✅ No waiting, ever

You lose PHPStorm's deep intelligence, but you gain speed and simplicity. For most Laravel development, this is more than enough.

Total setup time: 20 minutes Total cost: $99 for Sublime + $20 for Intelephense (optional) Speed improvement over PHPStorm: 10x startup, 5x search, ∞x less frustration