0

Xdebug (v2.6.1) for Atom (v1.34.0) is not working anymore (breakpoints are not fired at all) after the upgrade to mac-os Mojave. I was able to configure it successfully with High Sierra but after the upgrade I had problems with the httpd.conf of apache2 (I fixed it) and Xdebug does not work any longer.

Even though I found lots of answers related to this topic it didn't work for me any of them.

As you can see Xdebug is installed properly


    MacBook-Pro-6:~ francesco$ php -v
    PHP 7.1.13 (cli) (built: Feb  1 2018 13:38:42) ( NTS )
    Copyright (c) 1997-2017 The PHP Group
    Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies
        with Zend OPcache v7.1.13, Copyright (c) 1999-2017, by Zend Technologies
        with Xdebug v2.6.1, Copyright (c) 2002-2018, by Derick Rethans

this is the complete list of configuration settings


    MacBook-Pro-6:~ francesco$ php -i | grep xdebug
    /usr/local/php5/php.d/50-extension-xdebug.ini,
    xdebug
    xdebug support => enabled
    IDE Key => xdebug.atom
    xdebug.auto_trace => Off => Off
    xdebug.cli_color => 0 => 0
    xdebug.collect_assignments => Off => Off
    xdebug.collect_includes => On => On
    xdebug.collect_params => 0 => 0
    xdebug.collect_return => Off => Off
    xdebug.collect_vars => Off => Off
    xdebug.coverage_enable => On => On
    xdebug.default_enable => On => On
    xdebug.dump.COOKIE => no value => no value
    xdebug.dump.ENV => no value => no value
    xdebug.dump.FILES => no value => no value
    xdebug.dump.GET => no value => no value
    xdebug.dump.POST => no value => no value
    xdebug.dump.REQUEST => no value => no value
    xdebug.dump.SERVER => no value => no value
    xdebug.dump.SESSION => no value => no value
    xdebug.dump_globals => On => On
    xdebug.dump_once => On => On
    xdebug.dump_undefined => Off => Off
    xdebug.extended_info => On => On
    xdebug.file_link_format => no value => no value
    xdebug.filename_format => no value => no value
    xdebug.force_display_errors => Off => Off
    xdebug.force_error_reporting => 0 => 0
    xdebug.gc_stats_enable => Off => Off
    xdebug.gc_stats_output_dir => /var/tmp/ => /var/tmp/
    xdebug.gc_stats_output_name => gcstats.%p => gcstats.%p
    xdebug.halt_level => 0 => 0
    xdebug.idekey => xdebug.atom => xdebug.atom
    xdebug.max_nesting_level => 256 => 256
    xdebug.max_stack_frames => -1 => -1
    xdebug.overload_var_dump => 2 => 2
    xdebug.profiler_aggregate => Off => Off
    xdebug.profiler_append => Off => Off
    xdebug.profiler_enable => Off => Off
    xdebug.profiler_enable_trigger => On => On
    xdebug.profiler_enable_trigger_value => no value => no value
    xdebug.profiler_output_dir => /var/tmp/ => /var/tmp/
    xdebug.profiler_output_name => xdebug-profile-cachegrind.out-%H-%R => xdebug-profile-cachegrind.out-%H-%R
    xdebug.remote_addr_header => no value => no value
    xdebug.remote_autostart => Off => Off
    xdebug.remote_connect_back => On => On
    xdebug.remote_cookie_expire_time => 3600 => 3600
    xdebug.remote_enable => On => On
    xdebug.remote_handler => dbgp => dbgp
    xdebug.remote_host => 127.0.0.1 => 127.0.0.1
    xdebug.remote_log => no value => no value
    xdebug.remote_mode => req => req
    xdebug.remote_port => 9000 => 9000
    xdebug.remote_timeout => 200 => 200
    xdebug.scream => Off => Off
    xdebug.show_error_trace => Off => Off
    xdebug.show_exception_trace => Off => Off
    xdebug.show_local_vars => Off => Off
    xdebug.show_mem_delta => Off => Off
    xdebug.trace_enable_trigger => Off => Off
    xdebug.trace_enable_trigger_value => no value => no value
    xdebug.trace_format => 0 => 0
    xdebug.trace_options => 0 => 0
    xdebug.trace_output_dir => /var/tmp/ => /var/tmp/
    xdebug.trace_output_name => trace.%c => trace.%c
    xdebug.var_display_max_children => 128 => 128
    xdebug.var_display_max_data => 512 => 512
    xdebug.var_display_max_depth => 3 => 3

as you can see xdebug is enabled


    xdebug support => enabled 

the ide key is xdebug.atom


    IDE Key => xdebug.atom

the specific path of the xdebug.ini is at


    /usr/local/php5/php.d/50-extension-xdebug.ini

and this is the content of it


    zend_extension=/usr/local/php5/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so
    [xdebug]
    xdebug.idekey = xdebug.atom
    xdebug.remote_enable=1
    xdebug.remote_host=127.0.0.1
    xdebug.remote_connect_back=1    # Not safe for production servers
    xdebug.remote_port=9000
    xdebug.remote_handler=dbgp
    xdebug.remote_mode=req
    xdebug.remote_autostart=false
    xdebug.profiler_enable_trigger=1
    xdebug.profiler_output_name=xdebug-profile-cachegrind.out-%H-%R
    xdebug.var_display_max_children = 128
    xdebug.var_display_max_data = 512
    xdebug.var_display_max_depth = 3

by the way I tried configuring also the xdebug extension pre-installed at /usr/lib/php/extensions/no-debug-non-zts-20160303/xdebug.so with no luck.

xdebug.remote_autostart = false because I have Xdebug Helper for Chrome and ide.key is set to xdebug.atom

I installed php-debug package for Atom and this is my config.json


    "php-debug":
        ServerPort: 9000
        PathMaps: [
        "/remote/path;/local/path"
        "/Library/WebServer/repositories;/Library/WebServer/repositories"
        ]
        showWelcome: false

my remote and local path are the same because I need to debug my localhost. I am not sure if configuring the local path as remote path is an error but I remember in High Sierra Atom gave me suggestions on how to configure the paths and breakpoints were fired anyway so I am confident that's not the issue.

I tried to remove the paths, add the field ServerAddress, remove the field ServerPort with no luck.

of course I restarted apache every time I was doing some modification.

breack-points are not fired at all and I don't know what to do.

Do you have some idea about that? thank you very much.

As LazyOne pointed out the php7 loaded by Apache in the httpd.conf is the version pre-installed with Mojave

LoadModule php7_module libexec/apache2/libphp7.so

not the PHP 7.1.13 (cli) I installed.

if I try to set again

LoadModule php7_module /usr/local/php5-7.1.13-20180201-134129/libphp7.so

then the server fail to start and with sudo apachectl configtest I can see:

httpd: Syntax error on line 176 of /private/etc/apache2/httpd.conf: 
Cannot load /usr/local/php5-7.1.13-20180201-134129/libphp7.so into 
server: dlopen(/usr/local/php5-7.1.13-20180201-134129/libphp7.so, 10): 
no suitable image found.  Did find:\n\t/usr/local/php5-7.1.13- 
20180201-134129/libphp7.so: code signature in (/usr/local/php5-7.1.13- 
20180201-134129/libphp7.so) not valid for use in process using Library 
Validation: mapped file has no cdhash, completely unsigned? Code has 
to be at least ad-hoc signed.\n\t/usr/local/php5-7.1.13-20180201- 
134129/libphp7.so: stat() failed with errno=22

following this answer Apache not working after macOS Mojave update

I tried to replace the file to /usr/libexec/apache2/ like this sudo cp /usr/local/php5-7.1.13-20180201-134129/libphp7.so /usr/libexec/apache2/

but on the terminal I get always cp: /usr/libexec/apache2/libphp7.so: Operation not permitted

I followed all the steps mentioned here http://osxdaily.com/2018/10/09/fix-operation-not-permitted-terminal-error-macos/

but still Operation not permitted

do you have any idea how to configure the php7 is showed in the php -v?

  • Your `php -v` shows `PHP 7.1.13` .. while you are editing setting fro PHP 5 (based on `/usr/local/php5/...` file path. That might be the reason. Please check `phpinfo()` and `php -i` output -- at the very top it should list all config files that it has parsed .. so you may verify that you are editing the right config file. – LazyOne Jan 11 '19 at 12:09
  • I don't think this is a problem as you can see here as well https://coolestguidesontheplanet.com/upgrade-php-on-osx/ – Francesco Panella Jan 11 '19 at 13:37
  • 1
    That's fine .. but have you double checked that you are editing the right config files, the one that is used by your PHP version? Please also note that you may have different php.ini files used by the CLI environment and Apache (pretty common thing on Mac and Linux). – LazyOne Jan 11 '19 at 15:39
  • you're right, thank you but it still not working! now I have new issues (I edited the question to explain better) – Francesco Panella Jan 11 '19 at 20:00

1 Answers1

0

Basically the problem is this one https://github.com/liip/php-osx/issues/249 Because Mojave replace the httpd.conf of the built-in Apache (creating httpd.conf~previous as backup of the previous configuration) my apache was pointing to another version of php7 (the one built-in with Mojave in /usr/libexec/apache2/).

the php.ini of the php7 in the CLI has the Xdebug extension. the php.ini of the php7 built-in with Mojave does not.

that's why my debugger was not working but the server was, it was pointing to a functional version of php7 but without the extension of Xdebug.

I could just rename the old file httpd.conf~previous to reverse all the previous and working settings (my installed php7 version in /usr/local/php5-7.1.13-20180201-134129) but...there are some limitation with the built-in Apache in Mojave to read foreign libraries (it seems to be an issue that needs to be fixed by apple) and so pointing to my version php7 in CLI does not work.

httpd: Syntax error on line 176 of /private/etc/apache2/httpd.conf: 
Cannot load /usr/local/php5-7.1.13-20180201-134129/libphp7.so into 
server: dlopen(/usr/local/php5-7.1.13-20180201-134129/libphp7.so, 10): 
no suitable image found.

is the response typing sudo apachectl configtest

To fix this I had to copy the file /usr/local/php5-7.1.13-20180201-134129/libphp7.so in /usr/libexec/apache2/ but as mentioned before from the terminal I always got Operation not permitted.

That's because the folder /usr is protected by System Integrity Protection of MacOs and was not enough just giving Full Disk Access to the terminal.

I had to reboot the system in Recovery Mode and disable the SIP from the terminal with csrutil disable.

I followed this tutorial to do this http://osxdaily.com/2015/10/05/disable-rootless-system-integrity-protection-mac-os-x/

With the SIP disabled I was finally able to copy the php7 lib in apache with sudo cp /usr/local/php5-7.1.13-20180201-134129/libphp7.so /usr/libexec/apache2/

then restart the apache server and finally the debugger in Atom was working again.

for security then I enabled again the SIP in Recovery Mode with csrutil enable