Skip to content

Instantly share code, notes, and snippets.

@im4aLL
Created August 29, 2025 04:49
Show Gist options
  • Save im4aLL/297fb0c2be8d11d11f865d811f6b538d to your computer and use it in GitHub Desktop.
Save im4aLL/297fb0c2be8d11d11f865d811f6b538d to your computer and use it in GitHub Desktop.
Sublime text 4 + LSP + Prettier + PHP code format on windows 11

Instructions

  1. Install LSP and LSP-intelephense from Package Control.
  2. Restart
  3. Then run composer global require phpactor/phpactor
  4. Then in LSP settings
"clients": {
    "phpactor": {
        "enabled": true,
        "command": ["C:\\Users\\your_username_here\\AppData\\Roaming\\Composer\\vendor\\bin\\phpactor.bat", "language-server"],
        "selector": "source.php"
    }
}

Note: Provide client settings didn't work for https://lsp.sublimetext.io/language_servers/#php

Now prettier for HTML

  1. Install JsPrettier from package control
  2. Run npm install --global prettier
  3. Preferences / Package Settings / JsPrettier / Settings user
{
	"auto_format_on_save": true
}

It will format frontend files

Format for PHP

I tried using prettier php plugin, passed cli argument didn't work neither worked with prettier config file. Then I tried LSP format and it worked.

  1. Since you installed LSP, it comes with LSP format automatically
  2. Format on save will work only this way Preferences / Settings - Syntax Specific
{
	"lsp_format_on_save": true
}

Bonus setup

User settings

{
	"ignored_packages":
	[
		"Vintage",
	],
	"theme": "Spacegray Eighties.sublime-theme",
	"color_scheme": "Base16 Eighties Dark.sublime-color-scheme",
	"folder_exclude_patterns": ["node_modules", "vendor"],
	"font_face": "JetBrains Mono",
	"font_size": 10.5,
	"line_height": 1.7,
	"line_padding_top": 2,
	"line_padding_bottom": 2,
	"index_files": true
}

Installed packages list

  • A File Icon
  • Emmet
  • JsPrettier
  • LSP
  • LSP - intelephense
  • PHP companion
  • SideBarEnhancement
  • SublimeLinter
  • SublimeLinter - php
  • Theme - Spacegray
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment