PHP Composer errors with XDEBUG_MODE not recognized in VS Code

I am running VS Code. I have PHP installed locally, Composer installed locally and the VS Code Composer plugin installed in VS Code. From VS Code terminal, I pulled the GitHub master project and the pr/#XX that I am trying to clean up and merge

I made all my changes to my project repo branch and am now trying to test it, from the VS Code Terminal I ran the following:

composer install – downloads/installs all the required php files and packages

composer update – updates most of all the installed packages

composer test – on the project and it fails with:

XDEBUG_MODE=coverage vendor/bin/phpunit -c phpunit.dist.xml
‘XDEBUG_MODE’ is not recognized as an internal or external command,
operable program or batch file.

Through much reading, I added both to my php.ini file:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>xdebug.mode=coverage
XDEBUG_MODE=coverage
</code>
<code>xdebug.mode=coverage XDEBUG_MODE=coverage </code>
xdebug.mode=coverage
XDEBUG_MODE=coverage

What is happening and how can I fix this?


I found some docs on Xdebug here and cloned the xdebug.git (https://xdebug.org/docs/install#windows), then supplied my phpinfo() output to get the right downloaded php_xdebug.dll file to my php/ext folder and then added zend_extension = xdebug.

I verified Xdebug is enabled from CLI with: php -v

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>PHP 8.3.11 (cli) (built: Aug 27 2024 21:28:59) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans
</code>
<code>PHP 8.3.11 (cli) (built: Aug 27 2024 21:28:59) (ZTS Visual C++ 2019 x64) Copyright (c) The PHP Group Zend Engine v4.3.11, Copyright (c) Zend Technologies with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans </code>
PHP 8.3.11 (cli) (built: Aug 27 2024 21:28:59) (ZTS Visual C++ 2019 x64)
Copyright (c) The PHP Group
Zend Engine v4.3.11, Copyright (c) Zend Technologies
    with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans

I closed and restarted VS Code, but the composer test problem still persists.

I also removed the two xdebug_mode lines (above) from my php.ini file, to no effect.

7

Composer scripts cross-platform compatible environment variable setting (ref):

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>{
"scripts": {
"test": [
"@putenv XDEBUG_MODE=coverage",
"vendor/bin/phpunit -c phpunit.dist.xml"
]
}
}
</code>
<code>{ "scripts": { "test": [ "@putenv XDEBUG_MODE=coverage", "vendor/bin/phpunit -c phpunit.dist.xml" ] } } </code>
{
    "scripts": {
        "test": [
            "@putenv XDEBUG_MODE=coverage",
            "vendor/bin/phpunit -c phpunit.dist.xml"
         ]
    }
}

Recognized by PHP Collective

For anyone who has similar issues I was able to fix this AFTER installing XDebug locally on my Windows computer.

Specifically, in the composer.json file:

I changed:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>// a Linux variable setting
"scripts": {
"test": ["XDEBUG_MODE=coverage vendor/bin/phpunit -c phpunit.dist.xml"]
},
</code>
<code>// a Linux variable setting "scripts": { "test": ["XDEBUG_MODE=coverage vendor/bin/phpunit -c phpunit.dist.xml"] }, </code>
// a Linux variable setting
"scripts": {
    "test": ["XDEBUG_MODE=coverage vendor/bin/phpunit -c phpunit.dist.xml"]
},

To:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>"scripts": {
"test": ["vendor/bin/phpunit -c phpunit.dist.xml"]
},
</code>
<code>"scripts": { "test": ["vendor/bin/phpunit -c phpunit.dist.xml"] }, </code>
"scripts": {
    "test": ["vendor/bin/phpunit -c phpunit.dist.xml"]
},

And in my Windows php.ini file I had to set:
xdebug.mode=coverage

And then for notes purposes, I also added the following so others developers will know how the test works in each environment:

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<code>"scripts-descriptions": {
"test" : "Set PHP.ini xdebug.mode=coverage (windows) OR set 'test':['XMODE_DEBUG=coverage vendor/bin/phpunit ...'] (linux)"
}
</code>
<code>"scripts-descriptions": { "test" : "Set PHP.ini xdebug.mode=coverage (windows) OR set 'test':['XMODE_DEBUG=coverage vendor/bin/phpunit ...'] (linux)" } </code>
"scripts-descriptions": {
    "test" : "Set PHP.ini xdebug.mode=coverage (windows) OR set 'test':['XMODE_DEBUG=coverage vendor/bin/phpunit ...'] (linux)"
}

Credit to both @AlvaroGonzalez and @NicoHase for pointing me in the right direction.

2

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật