Visual Studio Code and php

Can phplint and phpcs be used with the Visual Studio Code Editor?
It seems like this is possible with Visual Studio Code tasks, right? If so, how?
Visual Studio Code Tasks

+3


source to share


1 answer


This is a very basic example of a PHPLint task for Visual Studio Code. It's not very difficult, but you will see that everything works.

It takes a more complex regex to correctly identify which lines are errors, which are warnings, and which don't matter at all.

{
    "command": "C:\\phplint\\phpl.bat",
    "version": "0.1.0",
    "args": [
        "C:\\Code\\index.php"
    ],
    "problemMatcher": {
        "fileLocation": ["relative", "${workspaceRoot}"],
        "pattern": {
            "regexp": "^(.*):(.*)$",
            "message": 1
        }
    }
}

      



I am using a custom task matching to parse the PHPLint output. The pattern has a regex that parses the output of PHPLint and then a list of what is at each position (in this case, I'm treating the entire string as a "message" - a little too basic, but you get the idea).

This is essentially how you create a task for anything you can get from the command line.

+2


source







All Articles