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, testsComposerdevsense.composer-php-vscode: composer.json support and Composer commandsIntelliPHPdevsense.intelli-php-vscode (0.12.17700): whole-line suggestions from an offline AI modelPHP Profilerdevsense.profiler-php-vscode: open and inspect Xdebug profiling filesPremium 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 seeActivate License / Begin Free Trial…Command Palette commands for the Premium featuresphpTools.suppressPremiumFeaturestrue: hide most Premium features and the messages about them (default false)Quick Settings…Command Palette: a page of the main optionsSupported PHP versions5.4 to 8.5, according to the extension's README badgeSetup: 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 semicolonsphp.workspace.shortOpenTagauto (default), true, false: parse <? as a PHP tagphp.workspace.editorConfigforce (default), on, off, on+intellij, force+intellij: read .editorconfigphp.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 packagesphpTools.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, zhShipped defaultsphp.suggest.basic and php.validate.enable are set to false so VS Code's own basic PHP features do not duplicate this extensionCompletion & Hover
php.completion.parametersAfter choosing a function: parentheses (default), parameters, nonephp.completion.autoimportTypes outside the current namespace: auto-import (default), auto-import-grouped, fqn, none, hidephp.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, hidephp.completion.namingConventioncamelCase (default), PascalCase, snake_case for generated namesphp.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, namedphp.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 Analysisphp.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 referencephp.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 workspaceImport class… / FQN class…Command Palette: add a use statement / write the fully qualified nameImplement class overrides…Command Palette: generate methods to overrideFormatting
php.format.codeStylePSR-12 (default), PER, PSR-2, Allman, K&R, Laravel, WordPress, Drupal, Joomla, PHP Tools, Offphp.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 decidesphp.format.rules.importSorting(Premium) off, alphabetic, byLength: how Organize imports sorts usephp.format.rules.openBraceOnNewLineFor…(Premium) Brace placement for functions, types, blocks, lambdas, namespacesphp.format.rules.blankLinesAfter… / Before…(Premium) Number of blank lines (keep, 0, 1, 2, 3) around classes, methods, namespaces and so onphp.format.rules.…Wrap(Premium) off, onEveryItem, always for arrays, parameters, attributes, chained callsphp.format.rules.space… / align…(Premium) Spaces in and around syntax, and aligning assignments, constants, properties, match armsFormat Multiple FilesCommand Palette: batch-format PHP files in the workspace, with a previeweditor.formatOnSave / formatOnTypeFormat on save; formatOnType is also needed for DocBlock generationDocBlock 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 filephp.docblock.functionSnippetTags above functions and methodsphp.docblock.propertySnippet / variableSnippetTags above properties / variable assignmentsphp.docblock.getterSetterSnippetTemplate for DocBlocks made by the getter/setter code actionphp.docblock.colorModeColouring of DocBlocksphp.completion.getterSnippet / setterSnippetCode placed inside generated getters and settersVariablesSnippet values may use VS Code snippet variables such as $CURRENT_YEARDebugging 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 Xdebugprogram / args / cwdThe script to run, its arguments and its folderruntimeExecutable / runtimeArgsA specific php program, or extra options for the built-in web serverport / 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 sentenv / envFile / XdebugSettingsEnvironment and Xdebug display limitsignoreExceptions / skipEntryPaths / excludeExceptions to ignore, entry files to skip, paths not to debugdbgpProxy / maxConnections / externalConsoleProxy address, simultaneous sessions, run in an external consoleprofile / openProfileProfile the run with Xdebug and open the resultStart Listening for XdebugCommand Palette: wait for a debug connection from a web serverDebug PHP script / Run PHP ScriptCommand Palette: debug or just run the current fileStart Debugging and Stop on EntryBound to F10 and F11 when no debugging session is runningTesting (PHPUnit and Pest)
Test ExplorerLists PHPUnit, Paratest and Pest tests; run or debug all, a suite, one test or one datasetphpunit.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 testsComposer, 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 commandsComposer: 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 resultsintelliphp.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 ClassWordPressWordPress stubs, hooks completion and WordPress code styleCodeIgniter 3, PestDynamic services for CodeIgniter 3; Pest tests in the Test ExplorerPHPStan / PsalmTheir annotations and generics are understood in IntelliSenseA 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 promptsGetting 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.