Closed llaville closed 10 months ago
And here are what I get with PHP Reflection API (script with results inside) :
Thanks @derickr for your swift response !
I'm currently rebuilding my docker image with blackfire
extension before xdebug
, and I'll keep you aware of new results ASAP
@derickr I'll try to reduce perimeter of extensions loaded to try to find origin of this conflict.
It seems that it's not blackfire
at origin of this issue.
Keep you aware of my investigations ASAP
I've a bad new : I've just tried only with xdebug
extension loaded, and I get same results
PHP 8.1.26 (cli) (built: Nov 27 2023 23:13:04) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.26, Copyright (c) Zend Technologies
with Xdebug v3.3.0, Copyright (c) 2002-2023, by Derick Rethans
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
hash
iconv
json
libxml
mbstring
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
readline
Reflection
session
SimpleXML
sodium
SPL
sqlite3
standard
tokenizer
xdebug
xml
xmlreader
xmlwriter
zlib
[Zend Modules]
Xdebug
For @mlocati
Dockerfile install only xdebug
others extensions are standard PHP bundled
ARG DOCKER_PHP_EXTENSION_INSTALLER=2.1.68
ADD https://github.com/mlocati/docker-php-extension-installer/releases/download/${DOCKER_PHP_EXTENSION_INSTALLER}/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions
FROM builder as build-version-8126
RUN install-php-extensions xdebug
The problem is that there's no constant defined by the xdebug PHP extension?
@mlocati No there are constants available. See https://git.remirepo.net/cgit/rpms/php/pecl/php-pecl-xdebug3.git/tree/REFLECTION?id=f818d63bb1ee19cb9b7bd54dffcd84d38a108a68 (thanks to @remicollet to provide such history in his repo)
And FYI, my project (PHP CompatInfo DB) follows extensions history, and is able to provide such content :
bin/compatinfo-db db:show xdebug --constants
Constants
---------
EXT min/Max PHP min/Max Deprecated Parameters Flags Dependencies Polyfills
XDEBUG_CC_BRANCH_CHECK 2.3.0 5.4.0
XDEBUG_CC_DEAD_CODE 2.0.0RC1 4.3.0
XDEBUG_CC_UNUSED 2.0.0beta2 4.3.0
XDEBUG_FILTER_CODE_COVERAGE 2.6.0beta1 => 2.9.8 7.0.0
XDEBUG_FILTER_NONE 2.6.0beta1 => 2.9.8 7.0.0
XDEBUG_FILTER_STACK 3.0.2 7.2.0
XDEBUG_FILTER_TRACING 3.0.2 7.2.0
XDEBUG_NAMESPACE_BLACKLIST 2.6.0beta1 => 2.9.8 7.0.0 => 7.4.33
XDEBUG_NAMESPACE_WHITELIST 2.6.0beta1 => 2.9.8 7.0.0 => 7.4.33
XDEBUG_PATH_BLACKLIST 2.6.0beta1 => 2.9.8 7.0.0 => 7.4.33
XDEBUG_PATH_WHITELIST 2.6.0beta1 => 2.9.8 7.0.0 => 7.4.33
XDEBUG_STACK_NO_DESC 2.3.0 => 2.9.8 5.4.0
XDEBUG_TRACE_APPEND 2.0.0beta1 => 2.9.8 4.3.0
XDEBUG_TRACE_COMPUTERIZED 2.0.0beta1 => 2.9.8 4.3.0
XDEBUG_TRACE_FLAMEGRAPH_COST 3.3.0alpha3 8.0.0
XDEBUG_TRACE_FLAMEGRAPH_MEM 3.3.0alpha3 8.0.0
XDEBUG_TRACE_HTML 2.0.0RC1 => 2.9.8 4.3.0
XDEBUG_TRACE_NAKED_FILENAME 2.3.0 => 2.9.8 5.4.0
Total [18]
OK got it ! Issue come from sapi used :
With php:8.x-fpm
base docker images xdebug constants are not available, while with php:8.x-cli
base docker image it's OK !
Results follow
With following Dockerfile
# syntax=docker/dockerfile:1
ARG PHP_VERSION=8.1
FROM php:${PHP_VERSION}-cli as builder
ARG DOCKER_PHP_EXTENSION_INSTALLER=2.1.68
ADD https://github.com/mlocati/docker-php-extension-installer/releases/download/${DOCKER_PHP_EXTENSION_INSTALLER}/install-php-extensions /usr/local/bin/
RUN chmod uga+x /usr/local/bin/install-php-extensions
FROM builder as build-version-8126
RUN install-php-extensions xdebug
Build image with : docker buildx build --progress plain .
docker run --rm -it f16600137485 php -v
PHP 8.1.26 (cli) (built: Nov 27 2023 23:05:31) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.26, Copyright (c) Zend Technologies
with Xdebug v3.3.0, Copyright (c) 2002-2023, by Derick Rethans
docker run --rm -it f16600137485 php --re xdebug
prints
@derickr Could we expect a fix for xdebug
extension ?
You haven't shown me what the problem is. Just a bunch of Docker stuff isn't going to help me find anything.
File a bug at https://bugs.xdebug.org with full reproduce steps, which shows that xdebug is directly causing the problem, so I can have a look.
@derickr If I provide such info, is it enough for you ?
On my native Ubuntu 22.04 LTS platform (not into a Docker container), with at least PHP 8.1 and xdebug 3.1.2 installed.
With such test case
--TEST--
Test Xdebug with Reflection API and PHP cli version
--DESCRIPTION--
This test proves that Xdebug extension is not able to provide its constants via the PHP Reflection API on cli SAPI
--SKIPIF--
<?php if (!extension_loaded("xdebug")) die("Skipped: xdebug extension required."); ?>
--EXTENSIONS--
xdebug
--FILE--
<?php
$ext = new ReflectionExtension('xdebug');
$constants = $ext->getConstants();
var_dump(array_keys($constants));
--EXPECT--
array(18) {
"XDEBUG_STACK_NO_DESC",
"XDEBUG_CC_UNUSED",
"XDEBUG_CC_DEAD_CODE",
"XDEBUG_CC_BRANCH_CHECK",
"XDEBUG_FILTER_CODE_COVERAGE",
"XDEBUG_FILTER_STACK",
"XDEBUG_FILTER_TRACING",
"XDEBUG_FILTER_NONE",
"XDEBUG_PATH_INCLUDE",
"XDEBUG_PATH_EXCLUDE",
"XDEBUG_NAMESPACE_INCLUDE",
"XDEBUG_NAMESPACE_EXCLUDE",
"XDEBUG_TRACE_APPEND",
"XDEBUG_TRACE_COMPUTERIZED",
"XDEBUG_TRACE_FLAMEGRAPH_COST",
"XDEBUG_TRACE_FLAMEGRAPH_MEM",
"XDEBUG_TRACE_HTML",
"XDEBUG_TRACE_NAKED_FILENAME"
}
I got these results :
Do you have xdebug.mode=off perchance?
Add that to the test case by using var_dump(xdebug_info('mode'));
Because in that case, xdebug does do the least amount of work. Currently including not registering constants.
Sorry but this time it's me that do not understand what you want ?
Sorry but this time it's me that do not understand what you want ?
@llaville what's the output of the following?
php -r "var_dump(xdebug_info('mode'));"
In the test case that you showed, please.
I got an empty array
================================================================================
/home/llaville/devilbox_data/bartlett/php-compatinfo-db/tests/unit/xdebug-constants.phpt
================================================================================
array(0) {
}
array(0) {
}
================================================================================
001- array(18) {
002- "XDEBUG_STACK_NO_DESC",
003- "XDEBUG_CC_UNUSED",
004- "XDEBUG_CC_DEAD_CODE",
005- "XDEBUG_CC_BRANCH_CHECK",
006- "XDEBUG_FILTER_CODE_COVERAGE",
007- "XDEBUG_FILTER_STACK",
008- "XDEBUG_FILTER_TRACING",
009- "XDEBUG_FILTER_NONE",
010- "XDEBUG_PATH_INCLUDE",
011- "XDEBUG_PATH_EXCLUDE",
012- "XDEBUG_NAMESPACE_INCLUDE",
013- "XDEBUG_NAMESPACE_EXCLUDE",
014- "XDEBUG_TRACE_APPEND",
015- "XDEBUG_TRACE_COMPUTERIZED",
016- "XDEBUG_TRACE_FLAMEGRAPH_COST",
017- "XDEBUG_TRACE_FLAMEGRAPH_MEM",
018- "XDEBUG_TRACE_HTML",
019- "XDEBUG_TRACE_NAKED_FILENAME"
001+ array(0) {
002+ }
003+ array(0) {
}
================================================================================
@llaville what's the output of the following?
php -r "var_dump(xdebug_info('mode'));"
outside test case, on command prompt I got
array(1) { [0] => string(7) "develop" }
For my test modified as
--FILE--
<?php
$ext = new ReflectionExtension('xdebug');
$constants = $ext->getConstants();
var_dump(array_keys($constants));
var_dump(xdebug_info('mode'));
It's maybe run-tests.php
that alters the xdebug configuration? See https://github.com/php/php-src/blob/php-8.1.26/run-tests.php#L904
@mlocati Thanks to point it to me. After disabled this line, I got new results (remember it's only on xdebug 3.1.2)
================================================================================
/home/llaville/devilbox_data/bartlett/php-compatinfo-db/tests/unit/xdebug-constants.phpt
================================================================================
/home/llaville/devilbox_data/bartlett/php-compatinfo-db/tests/unit/xdebug-constants.php:6:
array(16) {
[0] =>
string(20) "XDEBUG_STACK_NO_DESC"
[1] =>
string(16) "XDEBUG_CC_UNUSED"
[2] =>
string(19) "XDEBUG_CC_DEAD_CODE"
[3] =>
string(22) "XDEBUG_CC_BRANCH_CHECK"
[4] =>
string(27) "XDEBUG_FILTER_CODE_COVERAGE"
[5] =>
string(19) "XDEBUG_FILTER_STACK"
[6] =>
string(21) "XDEBUG_FILTER_TRACING"
[7] =>
string(18) "XDEBUG_FILTER_NONE"
[8] =>
string(19) "XDEBUG_PATH_INCLUDE"
[9] =>
string(19) "XDEBUG_PATH_EXCLUDE"
[10] =>
string(24) "XDEBUG_NAMESPACE_INCLUDE"
[11] =>
string(24) "XDEBUG_NAMESPACE_EXCLUDE"
[12] =>
string(19) "XDEBUG_TRACE_APPEND"
[13] =>
string(25) "XDEBUG_TRACE_COMPUTERIZED"
[14] =>
string(17) "XDEBUG_TRACE_HTML"
[15] =>
string(27) "XDEBUG_TRACE_NAKED_FILENAME"
}
/home/llaville/devilbox_data/bartlett/php-compatinfo-db/tests/unit/xdebug-constants.php:8:
array(1) {
[0] =>
string(7) "develop"
}
================================================================================
001- array(18) {
002- "XDEBUG_STACK_NO_DESC",
003- "XDEBUG_CC_UNUSED",
004- "XDEBUG_CC_DEAD_CODE",
005- "XDEBUG_CC_BRANCH_CHECK",
006- "XDEBUG_FILTER_CODE_COVERAGE",
007- "XDEBUG_FILTER_STACK",
008- "XDEBUG_FILTER_TRACING",
009- "XDEBUG_FILTER_NONE",
010- "XDEBUG_PATH_INCLUDE",
011- "XDEBUG_PATH_EXCLUDE",
012- "XDEBUG_NAMESPACE_INCLUDE",
013- "XDEBUG_NAMESPACE_EXCLUDE",
014- "XDEBUG_TRACE_APPEND",
015- "XDEBUG_TRACE_COMPUTERIZED",
016- "XDEBUG_TRACE_FLAMEGRAPH_COST",
017- "XDEBUG_TRACE_FLAMEGRAPH_MEM",
018- "XDEBUG_TRACE_HTML",
019- "XDEBUG_TRACE_NAKED_FILENAME"
001+ /home/llaville/devilbox_data/bartlett/php-compatinfo-db/tests/unit/xdebug-constants.php:6:
002+ array(16) {
003+ [0] =>
004+ string(20) "XDEBUG_STACK_NO_DESC"
005+ [1] =>
006+ string(16) "XDEBUG_CC_UNUSED"
007+ [2] =>
008+ string(19) "XDEBUG_CC_DEAD_CODE"
009+ [3] =>
010+ string(22) "XDEBUG_CC_BRANCH_CHECK"
011+ [4] =>
012+ string(27) "XDEBUG_FILTER_CODE_COVERAGE"
013+ [5] =>
014+ string(19) "XDEBUG_FILTER_STACK"
015+ [6] =>
016+ string(21) "XDEBUG_FILTER_TRACING"
017+ [7] =>
018+ string(18) "XDEBUG_FILTER_NONE"
019+ [8] =>
020+ string(19) "XDEBUG_PATH_INCLUDE"
021+ [9] =>
022+ string(19) "XDEBUG_PATH_EXCLUDE"
023+ [10] =>
024+ string(24) "XDEBUG_NAMESPACE_INCLUDE"
025+ [11] =>
026+ string(24) "XDEBUG_NAMESPACE_EXCLUDE"
027+ [12] =>
028+ string(19) "XDEBUG_TRACE_APPEND"
029+ [13] =>
030+ string(25) "XDEBUG_TRACE_COMPUTERIZED"
031+ [14] =>
032+ string(17) "XDEBUG_TRACE_HTML"
033+ [15] =>
034+ string(27) "XDEBUG_TRACE_NAKED_FILENAME"
035+ }
036+ /home/llaville/devilbox_data/bartlett/php-compatinfo-db/tests/unit/xdebug-constants.php:8:
037+ array(1) {
038+ [0] =>
039+ string(7) "develop"
}
================================================================================
@mlocati This is probably the reason why we did not get xdebug constants on Docker container .
Version => 3.3.0
Support Xdebug on Patreon, GitHub, or as a business: https://xdebug.org/support
Enabled Features (through 'xdebug.mode' setting)
Feature => Enabled/Disabled
Development Helpers => ✘ disabled
Coverage => ✘ disabled
GC Stats => ✘ disabled
Profiler => ✘ disabled
Step Debugger => ✘ disabled
Tracing => ✘ disabled
Optional Features
Compressed File Support => no
Clock Source => clock_gettime
'xdebug://gateway' pseudo-host support => yes
'xdebug://nameserver' pseudo-host support => yes
Systemd Private Temp Directory => not enabled
Directive => Local Value => Master Value
xdebug.mode => no value => no value
And php -r "var_dump(xdebug_info('mode'));"
gave an empty array as result
@mlocati / @derickr It's OK now even on docker container.
We MUST just be sure that xdebug.mode
setting is not set to Off
I've put develop
by default and now Reflection API returns xdebug constants
😄 @remicollet have already the solution, but I don't saw it https://git.remirepo.net/cgit/rpms/php/pecl/php-pecl-xdebug3.git/tree/REFLECTION?id=f818d63bb1ee19cb9b7bd54dffcd84d38a108a68#n4
I will change this in Xdebug though. These constants should always be there.
FWIW, I would be most happy if you configure the default to debug,develop as it would mean one less thing people need to change to make debugging work.
In any case, @llaville I think you can force the xdebug INI settings by adding this section to your test file:
--INI--
xdebug.mode=develop
--TEST--
Test Xdebug with Reflection API and PHP cli version
[...]
@mlocati BTW, the PHPT test case I've wrote was just for Derick to demonstrate issue outside of the Docker container.
I did not use elsewhere myself. But thanks anyways
Version of install-php-extensions
2.1.68
Error description
Hello @mlocati
To be really honest, I don't know if this issue is related to this project or if it come from
xdebug
extension itself. That is the reason why I'm /cc to @derickrThe API Reflection don't show me
constants
, when I run this command on CLI:php --re xdebug
, whileini entries
andfunctions
are all visible !The context : Build a docker image for the latest version of PHP 8.1, 8.2 and 8.3 with all possible extensions enable to test my project https://github.com/llaville/php-compatinfo-db Currently I'm working on branch
6.0
that will support PHP 8.3.0 and latestxdebug
v3.3.0 (stable).To understand possible origin, I gave all extensions I've installed in Dockerfile
Current results on Docker container
Docker image
php:8.1-fpm
Minimal Dockerfile