iamola / uniserver

The Uniform Server Git Repo
155 stars 18 forks source link

PHP xdebug configuration #16

Open dregad opened 2 months ago

dregad commented 2 months ago

I just installed the latest PHP 8.3.6 module, and realized that xdebug is no longer working.

I checked the bundled php.ini files, and the (out-of-the-box) configuration looks like this:

[xdebug]
;extension=xdebug
xdebug.remote_autostart=on
xdebug.remote_enable=on
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_mode=req
xdebug.idekey=default

OK, so the extension is not enabled... I uncommented the extension=xdebug line and restarted Apache, which now shows the following in the log:

[Tue May 07 14:15:14.830750 2024] [mpm_winnt:notice] [pid 7296:tid 448] AH00418: Parent: Created child process 19716
Xdebug: [Config] The setting 'xdebug.remote_autostart' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_autostart (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_enable' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_enable (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_host' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_host (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_mode' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_mode (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
Xdebug: [Config] The setting 'xdebug.remote_port' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.remote_port (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
PHP Warning:  Xdebug MUST be loaded as a Zend extension in Unknown on line 0
[Tue May 07 14:15:15.663955 2024] [mpm_winnt:notice] [pid 19716:tid 480] AH00354: Child: Starting 150 worker threads.

The first 5 lines are caused by obsolete Xdebug 2 directives, which should be converted to version 3 as appropriate (or possibly removed if the default value makes sense), see https://xdebug.org/docs/upgrade_guide for details.

Note: If I set an Xdebug 3 config, e.g. xdebug.mode=debug at this stage, the server does not start properly, a series of errors like below appear in the log:

[Tue May 07 14:31:02.629262 2024] [mpm_winnt:notice] [pid 12836:tid 456] AH00428: Parent: child process 15072 exited with status 3221225477 -- Restarting.
PHP Warning:  Xdebug MUST be loaded as a Zend extension in Unknown on line 0

This leads me to the warning

PHP Warning: Xdebug MUST be loaded as a Zend extension in Unknown on line 0 is caused by setting extension=xdebug instead of zend_extension=xdebug.

Restart Apache, and now it works.

I propose to change the default values in the bundled php*.ini files for all PHP versions

;zend_extension=xdebug
xdebug.mode=develop,debug
xdebug.start_upon_error=yes
xdebug.client_host=127.0.0.1

UniServer Zero XV 15.0.2 PHP 8.3.6 module

dregad commented 2 months ago

As a side note, I was wondering where the code to build the Modules is, couldn't find it on this repository... Is this documented somewhere ?

sudeepjd commented 2 months ago

If you are able to make changes to fix the issue of xdebug. Please submit PR with the fix to the config.ini file and we will merge in the code. Thanks.

The Modules are basically files from the respective packages, so there isn't code per se to update in UniServer itself.

dregad commented 2 months ago

Thanks for the feedback.

If you are able to make changes to fix the issue of xdebug. Please submit PR with the fix to the config.ini file and we will merge in the code. Thanks.

I would have done so right away, if I only I knew where to find the files that need to be modified. Did not find any trace of the strings from the [xdebug] section anywhere in the code base, hence my question about how the PHP modules are being built.

The Modules are basically files from the respective packages, so there isn't code per se to update in UniServer itself.

So you are saying that you are building those zip files manually, each time they need to be updated ? No automated or even semi-automated process at all ?

s-bourdon commented 2 months ago

Hello,

Thank you for the proposed changes. PHP 8.2.19 and 8.3.7 have been (manually 😉) updated and published.

Do not hesitate to let us know if you find anything else!

dregad commented 2 months ago

Thanks for the fix @s-bourdon , I have installed the updated modules today and confirmed that xdebug works OK now (after removing the ; of course).

Maybe as a convenience, it would be nice to have xdebug enabled by default in php_development.ini ?

Is the process to build the modules documented somewhere ? Didn't find that on the repo, wiki or website.

s-bourdon commented 2 months ago

Hello,

Your comments made me realize that «opcache» and «xdebug» modules are not being activated correctly when selected through the «PHP Modules Enable/Disable» menu in UniController.

Working on a fix right now! It will then be much easier to enable/disable these modules once fixed.

As for the process of building modules, it isn't documented anywhere; sorry! Maybe we'll look into that in the future.

Thank you!

s-bourdon commented 2 months ago

All php modules (7.0 to 8.3) have been fixed and updated on SourceForge

Many thanks for reporting that bug!