VS Code PHP (DEVSENSE) Cheat Sheet

Sidebar

Programming · VS Code PHP (DEVSENSE) Cheat Sheet

The DEVSENSE PHP extensions: PHP Tools, Composer, IntelliPHP and PHP Profiler. Settings, commands and the Xdebug launch configuration, with the Premium features marked. Checked against PHP Tools 1.74.19252, Composer 1.74.19252, IntelliPHP 0.12.17700 and PHP Profiler 1.74.19252 installed here. Sheet 23 in the VS Code series, and the last of the extensions installed on this machine.

The DEVSENSE Bundle & Its Licence

PHP Toolsdevsense.phptools-vscode (1.74.19252 here): IntelliSense, formatter, analysis, debugger, tests
Composerdevsense.composer-php-vscode: composer.json support and Composer commands
IntelliPHPdevsense.intelli-php-vscode (0.12.17700): whole-line suggestions from an offline AI model
PHP Profilerdevsense.profiler-php-vscode: open and inspect Xdebug profiling files
Premium featuresThe README marks these as Premium: starred suggestions, call and type hierarchy, code actions, inline refactorings, code fixes, code lenses, inlay hints, IntelliPHP, custom format rules, debug adornments, problem quick fixes and profiling tests. Whether your copy has them unlocked depends on your licence, which I cannot see
Activate License / Begin Free Trial…Command Palette commands for the Premium features
phpTools.suppressPremiumFeaturestrue: hide most Premium features and the messages about them (default false)
Quick Settings…Command Palette: a page of the main options
Supported PHP versions5.4 to 8.5, according to the extension's README badge

Setup: PHP Version, Paths & Indexing

php.executablePathPath to the php program (default none: found automatically)
php.executablesNamed PHP builds, e.g. { "8.3": "C:/php83/php.exe" } (default none)
php.versionA PHP version number or one of the names above; chosen with Select PHP version…
php.stubsExtension stubs used for IntelliSense (default ["*"], meaning all)
php.workspace.includePathExtra folders holding PHP declarations, separated by semicolons
php.workspace.shortOpenTagauto (default), true, false: parse <? as a PHP tag
php.workspace.editorConfigforce (default), on, off, on+intellij, force+intellij: read .editorconfig
php.files.excludeGlobs left out of indexing (default none)
php.cache.locationFolder for the cache of Composer packages (default none)
Clear /vendor/ cache.Command Palette: rebuild the IntelliSense cache for installed packages
phpTools.parallelismLimitMost threads used for indexing and analysis (default: automatic)
phpTools.languageLanguage of the built-in PHP manual: en, de, es, fr, it, ja, pt, ru, zh
Shipped defaultsphp.suggest.basic and php.validate.enable are set to false so VS Code's own basic PHP features do not duplicate this extension

Completion & Hover

php.completion.parametersAfter choosing a function: parentheses (default), parameters, none
php.completion.autoimportTypes outside the current namespace: auto-import (default), auto-import-grouped, fqn, none, hide
php.completion.docblockGenerate a DocBlock when you type /** (default true; needs editor.formatOnType)
php.completion.showNamespaceLabel / showParametersShow the namespace / the signature in the list (default true for both)
php.completion.showDeprecatedshowStrikethrough (default), showNormal, hide
php.completion.namingConventioncamelCase (default), PascalCase, snake_case for generated names
php.completion.starredSuggestions(Premium) Mark the likeliest completions with a star (default true)
php.completion.intelliPHP.preSelect(Premium) Pre-select the AI's choice (default false)
php.hover.parameters / hover.documentationParameter descriptions and documentation link in tooltips (default true)
php.hover.fullname / hover.parametersFullNameShow fully qualified names (default false)
php.hover.containingClassShow a member's class (default true)
php.sortUses.caseSensitiveCase-sensitive sorting of use statements (default false)
php.linkedEditing.variablesRename variables together with editor.linkedEditing (default false)

Inlay Hints & Code Lens (Premium)

php.codeLens.enabledReference counts and other lenses (default true)
php.codeActions.enabledQuick fixes and code actions (default true)
php.inlayHints.parameters.enabledShow parameter names at call sites (default true)
php.inlayHints.parameters.suppressNameMatchingValueHide a name that equals the argument (default false)
php.inlayHints.parameters.byReferenceShow & for by-reference arguments (default true)
php.inlayHints.types.returnInferred return types: true (default), false, named
php.inlayHints.types.variableInferred variable types (default false)
php.inlayHints.types.lambdaParameterInferred lambda parameter types (default true)
php.inlayHints.types.suppressVariableFromLiteralSkip obvious assignments such as $a = 1 (default true)
php.inlayHints.insertOnDoubleClickDouble-click a hint to insert it as code (default true)

Problems, Navigation & To-Dos

php.problems.scopeWhich files are analysed: opened (default), all, none; also the command Background Code Analysis
php.problems.excludePath patterns whose problems are not reported (default none)
php.problems.excludeGitIgnoreDo not report problems in files listed in .gitignore (default false)
php.navigation.referencesScopeany (default) or strict: what counts as a reference
php.highlight-todo.enableHighlight TODO and @todo comments (default true)
php.highlight-todo.styleTheir style (default { "backgroundColor": "#eecc00" })
Search todo…Command Palette: list every to-do in the workspace
Import class… / FQN class…Command Palette: add a use statement / write the fully qualified name
Implement class overrides…Command Palette: generate methods to override

Formatting

php.format.codeStylePSR-12 (default), PER, PSR-2, Allman, K&R, Laravel, WordPress, Drupal, Joomla, PHP Tools, Off
php.format.excludeGlob patterns of files not to format (default none)
php.format.rules.*(Premium) About a hundred individual rules that override the code style; unset (default) means the code style decides
php.format.rules.importSorting(Premium) off, alphabetic, byLength: how Organize imports sorts use
php.format.rules.openBraceOnNewLineFor…(Premium) Brace placement for functions, types, blocks, lambdas, namespaces
php.format.rules.blankLinesAfter… / Before…(Premium) Number of blank lines (keep, 0, 1, 2, 3) around classes, methods, namespaces and so on
php.format.rules.…Wrap(Premium) off, onEveryItem, always for arrays, parameters, attributes, chained calls
php.format.rules.space… / align…(Premium) Spaces in and around syntax, and aligning assignments, constants, properties, match arms
Format Multiple FilesCommand Palette: batch-format PHP files in the workspace, with a preview
editor.formatOnSave / formatOnTypeFormat on save; formatOnType is also needed for DocBlock generation

DocBlock Snippets

php.docblock.classSnippetTags added above classes, interfaces, traits and enums, e.g. { "@author": "John", "@copyright": "(c) $CURRENT_YEAR" }
php.docblock.packageSnippetTags at the top of a file
php.docblock.functionSnippetTags above functions and methods
php.docblock.propertySnippet / variableSnippetTags above properties / variable assignments
php.docblock.getterSetterSnippetTemplate for DocBlocks made by the getter/setter code action
php.docblock.colorModeColouring of DocBlocks
php.completion.getterSnippet / setterSnippetCode placed inside generated getters and setters
VariablesSnippet values may use VS Code snippet variables such as $CURRENT_YEAR

Debugging with Xdebug (launch.json type: php)

type / request"type": "php", "request": "launch"
php.debug.portDefault Xdebug port(s) when port is not set (default [9003, 9000])
Snippets in launch.jsonLaunch built-in server, Launch & Profile built-in server, Launch current script in console, Listen for Xdebug
program / args / cwdThe script to run, its arguments and its folder
runtimeExecutable / runtimeArgsA specific php program, or extra options for the built-in web server
port / hostnameWhere the debugger listens (Xdebug 3 default port 9003)
pathMappingsMap server folders to local ones, e.g. { "/var/www": "${workspaceFolder}" }
stopOnEntry / noDebug / triggerPause at the first line / run without debugging / only debug when a trigger is sent
env / envFile / XdebugSettingsEnvironment and Xdebug display limits
ignoreExceptions / skipEntryPaths / excludeExceptions to ignore, entry files to skip, paths not to debug
dbgpProxy / maxConnections / externalConsoleProxy address, simultaneous sessions, run in an external console
profile / openProfileProfile the run with Xdebug and open the result
Start Listening for XdebugCommand Palette: wait for a debug connection from a web server
Debug PHP script / Run PHP ScriptCommand Palette: debug or just run the current file
Start Debugging and Stop on EntryBound to F10 and F11 when no debugging session is running

Testing (PHPUnit and Pest)

Test ExplorerLists PHPUnit, Paratest and Pest tests; run or debug all, a suite, one test or one dataset
phpunit.phpunitPath to the PHPUnit binary (default none: found in vendor, bin or a .phar)
phpunit.configPath or glob for phpunit.xml (default none)
phpunit.commandThe command template; variables ${php}, ${phpargs}, ${phpunit}, ${phpunitargs}, ${phpunitxml}
phpunit.enableAutomaticRefreshRefresh the test list when files change (default true)
phpunit.preTask / phpunit.postTaskTasks from tasks.json to run before / after tests

Composer, Profiler & IntelliPHP

composer.workingPathFolder containing composer.json and vendor (default: workspace root)
composer.binPath to a specific composer.phar (default: found automatically)
composer.inlayVersionEnabledShow the installed version beside each package in composer.json (default true)
composer.diagnosticsEnabledWarn about abandoned packages (default true)
Composer: install / update / require package… / require dev package… / remove package…Command Palette: the main Composer commands
Composer: outdated / show --tree / run-script… / create-project… / search…More Composer commands (also licenses, fund, archive, reinstall, clear-cache)
phpprofiler.hotpath.tresholdPercent of time (0 to 100) above which a line is highlighted as a hot path (default 1)
Open Profile File (Xdebug Profiling Output) / Load CacheGrind ProfileCommand Palette: open profiling results
intelliphp.inlineSuggestionsEnabledAI whole-line inline suggestions (default true; a Premium feature)

Frameworks (from the README)

LaravelBlade highlighting, completion and formatting; Eloquent magic; routes, views, components, Livewire; command Switch between Blade View and Class
WordPressWordPress stubs, hooks completion and WordPress code style
CodeIgniter 3, PestDynamic services for CodeIgniter 3; Pest tests in the Test Explorer
PHPStan / PsalmTheir annotations and generics are understood in IntelliSense

A Reasonable Starter Set (my suggestions, not defaults)

"php.format.codeStyle": "PSR-12"The default; set it explicitly so the team's choice is visible
"editor.formatOnSave": trueFormat PHP when you save
"[php]": { "editor.defaultFormatter": "DEVSENSE.phptools-vscode" }Make the PHP formatter explicit
"php.problems.scope": "opened"Fast, quiet analysis (the default)
"php.inlayHints.types.variable": trueMore hints, if you have Premium and like them
"phpTools.suppressPremiumFeatures": trueIf you do not use Premium and want fewer prompts
Getting Xdebug working
The debugger needs the Xdebug extension in your PHP installation. In php.ini that usually means a zend_extension line for Xdebug, xdebug.mode=debug, and xdebug.start_with_request=yes (or trigger); Xdebug 3 connects back to port 9003, which is why that is first in php.debug.port. Run php -v in a terminal: its output names Xdebug when it is loaded. Then use Launch built-in server from the launch.json snippets to run and debug the site without Apache.
Two PHP extensions fighting each other?
This extension switches VS Code's own basic PHP suggestions and validation off by default. If you also install another PHP language extension (for example Intelephense), you may get double completions, duplicate errors or conflicting formatters: keep only one active for each job. Check Extensions > @installed php and use Disable (Workspace) on the one you do not want in a given project.