Skip to content

Instantly share code, notes, and snippets.

@crittermike
Last active October 1, 2020 12:49
Show Gist options
  • Save crittermike/ebd48da243dc9b253da1726429d12b8f to your computer and use it in GitHub Desktop.
Save crittermike/ebd48da243dc9b253da1726429d12b8f to your computer and use it in GitHub Desktop.
Xdebug + PHPStorm for PHP 7 on Alpine Linux

First, install the Xdebug package from the testing repository.

$ apk add php7-xdebug --repository http://dl-3.alpinelinux.org/alpine/edge/testing/

Now edit the /etc/php7/php.ini file and add the following to the end of it:

zend_extension=/usr/lib/php7/modules/xdebug.so
xdebug.coverage_enable=0 
xdebug.remote_enable=1      
xdebug.remote_connect_back=1
xdebug.remote_log=/tmp/xdebug.log
xdebug.remote_autostart=true  

With everything in place, we're ready to restart the server.

$ nginx -s reload
$ /etc/init.d/php-fpm restart

At this point, in PHPStorm, click "Run > Start Listening for PHP Debug Connections", and then "Run > Break at first line in PHP Scripts".

Now reload the site in the browser, making sure to use the port that goes directly to the server, which is sometimes :8080 instead of :80, and you should see the debugger fire up.

@bkuhl
Copy link

bkuhl commented Jan 9, 2018

Came across this in a google search, just an FYI that repository no longer exists. Here's a quick list of them though: https://pkgs.alpinelinux.org/packages?name=php7-xdebug&branch=&repo=&arch=&maintainer=

@wmathes
Copy link

wmathes commented May 25, 2018

Looks good on first glance, but some minor additions:

  • reloading worked better for me using kill -s USR2 1
  • the config file might be somewhere else or get overwritten, use php --ini to see which files are actually loaded and in which order.

i still get Failed loading /usr/lib/php7/modules/xdebug.so: Error relocating /usr/lib/php7/modules/xdebug.so: vspprintf: symbol not found. though.

@aerlaut
Copy link

aerlaut commented Dec 1, 2018

Package php7-xdebug is going to be replaced by php7-pecl-xdebug in release Alpine 3.9.0 : https://bugs.alpinelinux.org/issues/9277.

However, this change is reflected in package search : https://pkgs.alpinelinux.org/packages?name=php7-pecl-xdebug&branch=edge.
Installing php7-pecl-xdebug will result in missing package. Package name in the repo is still php7-xdebug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment