Hướng dẫn php-cs-fixer php general error

I had the same error before and I solved it by running visual studio code as Administrator.

My environment:
Windows 8.1
PHP Version 5.4.31

VS setting for the extension:
{
"php-cs-fixer.executablePath": "C:\php-cs-fixer.phar",
"php-cs-fixer.onsave": false,
"php-cs-fixer.rules": "@psr2",
"php-cs-fixer.autoFixByBracket": true,
"php-cs-fixer.autoFixBySemicolon": false,
"php-cs-fixer.formatHtml": true,
}

VS code installed path:
C:\Program Files (x86)\Microsoft VS Code\

Mar 10, 2017 update
I found that if install VS code somewhere else rather than , like C:\Microsoft VS Code, then you don't need to "run as Administrator"


The folder does exist. or do you run the tool outside of the project directory?

current php_cs i use:

in([
    'app',
    'config',
    'database',
    'tests',
]);

return Config::create()
    ->setRules([
        '@Symfony' => true,
        'binary_operator_spaces' => ['align_double_arrow' => false, 'align_equals' => false],
        'combine_consecutive_unsets' => true,
        'concat_space' => false,
        'dir_constant' => true,
        'no_mixed_echo_print' => false,
        'ereg_to_preg' => true,
        'general_phpdoc_annotation_remove' => false,
        'phpdoc_no_alias_tag' => ['type' => 'var'],
        'header_comment' => false,
        'linebreak_after_opening_tag' => true,
        'array_syntax' => false,
        'modernize_types_casting' => true,
        'no_blank_lines_before_namespace' => false,
        'no_multiline_whitespace_before_semicolons' => true,
        'no_php4_constructor' => true,
        'no_short_echo_tag' => true,
        'no_useless_else' => true,
        'no_useless_return' => true,
        'not_operator_with_space' => false,
        'not_operator_with_successor_space' => false,
        'ordered_class_elements' => false,
        'ordered_imports' => true,
        'php_unit_construct' => true,
        'php_unit_dedicate_assert' => true,
        'php_unit_strict' => false,
        'phpdoc_order' => true,
        'psr0' => false,
        'psr4' => true,
        'random_api_migration' => true,
        'array_syntax' => ['syntax' => 'short'],
        'simplified_null_return' => true,
        'strict_comparison' => true,
        'strict_param' => true,
        'phpdoc_align' => false,
    ])
    ->setLineEnding("\r\n")
    ->setRiskyAllowed(true)
    ->setUsingCache(true)
    ->setFinder($finder);

All those folders exist:

Hướng dẫn php-cs-fixer php general error

I downloaded and installed PHP CS Fixer extension for VSCode (by junstyle) and the official php-cs-fixer-v2.phar file from https://github.com/FriendsOfPHP/PHP-CS-Fixer. I created a file named config.php-cs and pasted the reference config code in it :

return PhpCsFixer\Config::create()
    ->setRules(array(
        '@PSR2' => true,
        'array_indentation' => true,
         ....

I placed both those files in C:\wamp64\www\configuration_php\

Here is my settings.json

{
    "workbench.iconTheme": "file-icons",
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
    "editor.formatOnPaste": true,
    "workbench.colorTheme": "One Dark Pro",
    "editor.fontLigatures": true,
    "editor.lineHeight": 22,
    "files.trimTrailingWhitespace": true,
    "editor.fontWeight": "400",
    "editor.renderWhitespace": "all",
    "editor.tabSize": 2,
    "editor.cursorStyle": "line",
    "editor.insertSpaces": false,
    "prettier.useTabs": true,
    "terminal.integrated.fontSize": 15,
    "javascript.validate.enable": false,
    "editor.formatOnSave": true,
    "files.autoSave": "off",
    "window.zoomLevel": 0,
    "editor.fontFamily": "JetBrains Mono, Consolas, 'Courier New', monospace",
    "editor.cursorBlinking": "smooth",
    "editor.formatOnSaveTimeout": 5000,
    "php-cs-fixer.executablePath": "C:\\wamp64\\www\\configuration_php\\php-cs-fixer-v2.phar",
    "php-cs-fixer.config": "C:\\wamp64\\www\\configuration_php\\config.php_cs",
    "php-cs-fixer.onsave": true,
}

I can tell my editor considers the executablePath because if I put a mistake in the path, I get an error message. The problem is for the config path. VSCode seems to be ignoring it completely and won't use the config file or raise any error if I introduce mistakes in the path or in the file content.

Am I missing something ?