DEV Community

Cover image for The best setting.json for PHP development with Visual Studio Code

The best setting.json for PHP development with Visual Studio Code

ryan1 profile image ryan Updated on ・3 min read


PHP is a dynamic object-oriented language that brings the developer the power of OOP along with the flexibility of dynamic typing. Type annotations are supported in PHP which allows you the ability to define the runtime type of function parameters.

IDE’s can be used to increase one’s productivity since most of them have built-in auto-completion and other useful features such as “Go to definition”, and “Find all references”.
One popular IDE is PHPStorm, but today we will highlight which Visual Studio Code extensions transform Visual Studio Code into a full-fledged IDE alternative for PHP.

With great power, comes great responsibility, and because Visual Studio Code is a powerful text editor that brings an extremely powerful extensibility API, it’s easy to find yourself with a nonsensical settings.json file. At the end of this post, your visual studio code will have these productivity features:

  • Errors, warnings, and other introspection such as unused variables.
  • Code completion
  • Function/Method signature parameter hinting.
  • Go to definition
  • DotEnv syntax highlighting
  • Find all references
  • Documentation when hovering over methods
  • Path autocompletion, for string literal file paths.
  • PSR code sniffing emitting errors, and warnings in real time.
  • Automatic PHP DocBlocks.

These features will be implemented by installing these extensions:

TLDR; the full settings file is on GitHub.

Step 1.

The first thing we need to do is disable default PHP support. This can be accomplished with two configuration items in your .vscode/settings.json file. The snippets in this post are extracted from the full file.

 "php.validate.enable": false,
 "php.suggest.basic": false,

This will allow our extensions to be used to their fullest extent and prevent any functional collisions.

Step 2.

By default, the php-redis extension is not included in the default configuration. So that means you will not have auto-complete for the Redis class. Now, let’s configure optimal Intelephense settings. Quick tip, when you’re editing a setting.json file in vscode, you can see the default value for the configuration item by typing the colon character, : and then clicking the tooltip.

"intelephense.stubs": [
    "Zend OPcache",
"intelephense.telemetry.enabled": false,
"intelephense.format.enable": true,
"intelephense.completion.triggerParameterHints": true,
"intelephense.completion.insertUseDeclaration": true,
"intelephense.completion.fullyQualifyGlobalConstantsAndFunctions": true,
"intelephense.trace.server": "messages",
"intelephense.files.exclude": [

Step 3 PHP Code Sniffer settings

"phpcs.executablePath": "vendor/bin/phpcs",
"phpcs.enable": true,
"phpcs.autoConfigSearch": true,
"phpcs.standard": "./phpcs.xml",
"phpcs.showWarnings": true,
"phpcs.showSources": true,
"phpcs.ignorePatterns": [

Step 4. PHPDoc Block settings

"php-docblocker.returnGap": true,
"php-docblocker.qualifyClassNames": true,
"": {
    "name": "Ryan McCullagh", 
    "email": ""

Step 5. Optional settings.

These settings are more of a more personal flavor, but I’ve shared them here because I believe they are amazing.

"search.collapseResults": "alwaysCollapse",
"search.exclude": {
    "**/node_modules": true,
    "**/bower_components": true,
    "**/.git": true,
    "**/storage": true,
    "**/tests": true,
    "_ide_helper.php": true,
    "_ide_helper_models.php": true,
    "package-lock.json": true
"files.eol": "\n",
"files.insertFinalNewline": true,
"files.trimTrailingWhitespace": true,
"files.associations": {
    "*.blade.php": "html",
    "*.php": "php",
    "*.vue": "vue",
    "*.php-cs": "php"
"editor.fontSize": 14,
"editor.letterSpacing": 0.5,
"editor.lineHeight": 24,
"editor.cursorBlinking": "smooth",
"editor.fontLigatures": false,
"editor.formatOnType": false,
"editor.formatOnPaste": false,
"editor.autoIndent": "advanced",
"git.showPushSuccessNotification": true,
"editor.gotoLocation.multipleDefinitions": "goto",
"editor.snippetSuggestions": "bottom",
"workbench.editor.enablePreview": false,
"workbench.editor.enablePreviewFromQuickOpen": false,

The last 2 are great because the editor will stay open when you’ve navigated to a file from a find all reference, or go to definition click.


Editor guide
justaashir profile image
Aashir Aamir Khan

I love your presentation as you said 'Optional Settings' because I don't like the cursor blinking and I love the font ligatures. It's my taste, and I don't want anyone to tell me strictly to do this. It's my taste 😉

bpedroza profile image

What is powering the click to go to functionality? Does it work with composer packages?

I've had a hard time finding a package that does this well.

ryan1 profile image
ryan Author

Hi, yes it works with Composer packages. This is one of my favorite features since I believe code is the best form of documentation.

bsienn profile image
Abdul Rehman (Bsienn)

dockbloker link is broken