Skip to content

Installation guide - Visual Studio Code - Successful #31

@adrianvintu

Description

@adrianvintu

Visual Studio Code configuration

Go to https://github.com/FriendsOfPHP/PHP-CS-Fixer#installation and download the phar file
Link used to be https://cs.symfony.com/download/php-cs-fixer-v2.phar

File->Preferences->Settings
At north-east, there are two icons, one says "Open Settings" and will show you the settings in json mode. . Add your paths.

    "phpformatter.phpPath": "c:\\wamp\\bin\\php\\php7.4.9\\php.exe",
    "phpformatter.pharPath": "c:\\php_formatter\\php-cs-fixer.phar",
    "phpformatter.logging": true,
    "phpformatter.arguments": [
        "--rules=@PSR2"
    ],

The phpformatter.arguments PSR2 is required, seems to be a bug.

Debug info is visible here (phpformatter.logging):
View -> Command Palette ->Developer: Toggle Developer Tools -> Console

and looks like this:

console.ts:137 [Extension Host] PHPFormatter: Tempfile fd: 5
console.ts:137 [Extension Host] PHPFormatter: Tempfile name: c:\temp\phpfmt-21316hI7z3XLclzvd.tmp
console.ts:137 [Extension Host] PHPFormatter: Writing current document content to temp file. Until VSCode will have a way of querying encoding, utf8 will be used for reading and writing.
console.ts:137 [Extension Host] PHPFormatter: Full command being executed: "c:\wamp\bin\php\php7.4.9\php.exe" "c:\php_formatter\php-cs-fixer.phar" fix "c:\temp\phpfmt-21316hI7z3XLclzvd.tmp" --rules=@PSR2

Test that php-cs-fixer is installed:

php C:\php_formatter\php-cs-fixer.phar fix sample.php

I gathered this info from all the tickets. I hope it helps you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions