1

I built according to https://xdebug.org/docs/install from source, since pecl/pearl is broken:

pecl install xdebug
downloading xdebug-2.8.0.tgz ...
Starting to download xdebug-2.8.0.tgz (238,122 bytes)
.................................................done: 238,122 bytes
PHP Fatal error:  Cannot use result of built-in function in write context in /usr/share/php/Archive/Tar.php on line 639

After building, lib is in /usr/lib/php/20180731/xdebug.so. I added in /etc/php/7.3/apache2/php.ini:

[opcache]
...
[xdebug]
zend_extension=~"/usr/lib/php/20180731/xdebug.so"
xdebug.remote_enable = 1
xdebug.remote_autostart = 1

I restarted apache: service apache2 restart
I checked with service apache2 status.

When I run php -m, it shows

[Zend Modules]
Zend OPcache

but no XDebug. Output of php --version is:

PHP 7.3.12-1+ubuntu16.04.1+deb.sury.org+1 (cli) (built: Nov 28 2019 07:36:56) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.12, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.3.12-1+ubuntu16.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
root@HAL:/home/richard#

No XDebug also. So now I can't get XDebug to work with Visual Studio Code. Any ideas? Many thanks

jww
  • 97,681
  • 90
  • 411
  • 885
user2943111
  • 421
  • 1
  • 5
  • 15
  • @jww: thanks for the formatting and other changes, like insertion of "I" and "When" – user2943111 Dec 01 '19 at 10:32
  • You already have the "sury" package repos, why don't you use the Xdebug from there? – Ulrich Eckhardt Dec 01 '19 at 11:50
  • Because I have no idea what "sury" does? Anyway, I think I solved the issue. Thanks for your help. – user2943111 Dec 01 '19 at 12:58
  • https://launchpad.net/~ondrej -- you find various packages with and for various PHP versions for multiple operating systems. Your PHP version string says "7.3.12-1+ubuntu16.04.1+deb.sury.org+1", so you should be all set. – Ulrich Eckhardt Dec 01 '19 at 13:17
  • I have those breakpoints working now with the *.so file I built. Your way could work also (haven't tested this), but then I would need to find out what this sury package does and how to use that from within Visual Studio Code. Anyway, I will proceed with my actual work now, the debugger is just a tool, a means to an end. – user2943111 Dec 01 '19 at 14:28

2 Answers2

0

as usual, it was a stupid user (me) error. I had unzipped the source code for XDebug in Downloads folder. Then it was build in ~/Downloads/xdebug-2.8.0/modules and I also found a copy in ~/Downloads/xdebug-2.8.0/.libs.

So, first I had a path pointing into my home directory, starting with ~. I found out the *.so file had also been copied to /usr/lib/php/20180731/xdebug.so since I read here https://xdebug.org/docs/install:

zend_extension="/usr/local/php/modules/xdebug.so"

and I compared that to my own system. Now, here is the big blunder: while editing the path to "/usr/lib/php/20180731/xdebug.so", I forgot to remove the leading ~ !!!

Thus the module could not be loaded. An error message saying it could not find specified path/file would have been nice, since humans do make mistakes. Maybe there is such an error message hidden in some log file, I did not check. At least a warning to read the log file would have been great.

After removing this tilde and restarting the server, phpinfo shows XDebug module is loaded.

Sorry people for wasting your time. I guess many issues here arise from ignorance and stupidity and it shows I am not free of these ;-)

Perhaps it is pleading for me I resolved the issue myself.

Updated section in php.ini:

[xdebug]
zend_extension=/usr/lib/php/20180731/xdebug.so
xdebug.remote_enable = 1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_handler=dbgp
xdebug.remote_autostart = 1

Some was taken from The xdebug extension is not loaded

I hope this can be helpful to others.

user2943111
  • 421
  • 1
  • 5
  • 15
0

For those who use XDebug and thus probably are making a web site: I made a script like this (credits are all to Thomas Ward):

#!/bin/bash

# https://askubuntu.com/questions/767504/permissions-problems-with-var-www-html-and-my-own-home-directory-for-a-website
chgrp -R www-data /var/www/html
find /var/www/html -type d -exec chmod g+rx {} +
find /var/www/html -type f -exec chmod g+r {} +

chmod -R o-rwx /var/www/html/

chown -R richard /var/www/html/
find /var/www/html -type d -exec chmod u+rwx {} +
find /var/www/html -type f -exec chmod u+rw {} +

# This sets the "set gid" bit for the group on the directories.
# Files and folders created inside these directories will always have www-data as the group, 
# permitting the web server access
find /var/www/html -type d -exec chmod g+s {} +

After running this (usually just once), Visual Studio Code can write files underneath /var/www/html

Now you no longer are prompted to press OK and fill in root password while Visual Code wants to save files that changed inside your web project.

You would need to fill in your own username of course. The path /var/www/html could be /opt/lampp/htdocs in your case.

I hope this helps others.

user2943111
  • 421
  • 1
  • 5
  • 15