1

I'm struggling with setting up environment for old tech project with PHP5. My OS is Windows and I have installed so far VSCode plugins: PHP Debug, PHP Intelephense, PHPUnit, PHPUnit Test Explorer. I downloaded phpunit-5.7.27.phar and configured VSCode according to documentation.

Settings.json

{
    "php.validate.executablePath": "C:/wamp64/bin/php/php5.6.40/php.exe",
    "phpunit.phpunit": "C:/wamp64/bin/php/php5.6.40/phpunit-5.7.27.phar",
    "phpunit.php": "C:/wamp64/bin/php/php5.6.40/php.exe",
    "intelephense.environment.phpVersion": "5.6.40",
    "intelephense.environment.includePaths": [
        "C:/wamp64/bin/php/php5.6.40/phpunit-5.7.27.phar",
        "C:/wamp64/bin/php/php5.6.40/php.exe",
        "C:/wamp64/bin/php/php5.6.40/"
    ]

}

Launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Listen for XDebug",
            "type": "php",
            "request": "launch",
            "port": 9000,
            "xdebugSettings": {
                "max_children": 256,
                "max_data": 500,
                "max_depth": 3
            }
        },
    ]
}

What works for me fine is breakpointing on running app with xdebug and running unittests with Cmd+Shift+P.

What I need help with are as follows:

  1. Code editor shows error for PHP unit classes and methods (even though unittests are executing fine as is). Do I need to add to path something besides phar file? Is VSCode non-compatible with phar files? The same happens for PHPUnit\Framework\TestCase.
  2. I can't figure out how to configure Test Explorer plugin to show nicely tests tree. Does it require some configuration in Launch.json? Launching tests with Cmd+Shift+P displays results only in terminal.

Installed plugins and editor error on PHPUnit class

1 Answer 1

2
  1. PHP Intelephense requires installed PHPUnit with composer in workspace.
    composer require --dev phpunit/phpunit
    
  2. PHPUnit Test Explorer has by default Phpunit: Files setting set to {test,tests}/**/*Test.php, so changing it to proper glob should allow plugin to detect all tests.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.