Turn Sublime Text into An Awesome IDE for Laravel / PHP with LSP and Intelephense
I like Sublime Text. I really do. I like how fast it is, how versatile it is, and overall I have a very good experience with it.
Despite how popular VS Code has become recently, I find it just a little slow to my liking. Then there is also PHPStorm which is feature-packed, but a little heavy to my liking.
So what if we can add some IDE features to an ultra-fast editor? That would be great isn’t it? Well that’s totally possible!
- Go to your Terminal app and install
intelephense
by running:npm -g i intelephense
. - Open the command palette in Sublime Text and run
Package Control: Install Package
, then selectLSP
andLSP-intelephense
to install both packages. - Enable the server by running
LSP: Enable Language Server
in command palette. Then chooselsp-intelephense
from the menu. - Go to
LSP > Servers > LSP-intelephense
underPackage Settings
, copy and paste the following json into your settings file to setup LSP and Intelephense:
{
"enabled": true,
"command": [
"intelephense",
"--stdio",
],
"scopes": ["source.php", "embedding.php"],
"syntaxes": ["Packages/PHP/PHP.sublime-syntax"],
"languageId": "php",
"initializationOptions": {
"clearCache": false,
"licenceKey": "",
},
}
Now restart your Sublime Text and you are all done! You should now be able to autocomplete accurately.