Skip to content

Instantly share code, notes, and snippets.

@ohthehugemanatee
Created September 20, 2016 08:20
Show Gist options
  • Save ohthehugemanatee/33e46ffc125abdf11dfb6286cdcf5d36 to your computer and use it in GitHub Desktop.
Save ohthehugemanatee/33e46ffc125abdf11dfb6286cdcf5d36 to your computer and use it in GitHub Desktop.
once xdebug is working globally, we can enable it for the CLI. Note the alias 'xdebug-on'. Ideally there should be an xdebug-off, too...
#!/bin/bash
# Enable CLI xdebug when the IDEkey is available in environment.
# Run this script on the GUEST machine with `docker-compose exec drupal /var/www/drupal/public_html/enable-cli-xdebug.sh`
# use it with 'export XDEBUG_CONFIG="idekey=foobar"'
# Note: PHPStorm also requires 'export PHP_IDE_CONFIG="serverName=popo.docker.amazee.io"'
sudo rm /etc/php/7.0/cli/conf.d/20-xdebug.ini
sudo echo 'zend_extension=xdebug.so' > /etc/php/7.0/cli/conf.d/20-xdebug.ini
sudo echo 'xdebug.remote_enable = on' >> /etc/php/7.0/cli/conf.d/20-xdebug.ini
if grep --quiet dockerhost /etc/php/fpm-pool/drupal-xdebug.conf; then
sudo echo 'xdebug.remote_host = dockerhost' >> /etc/php/7.0/cli/conf.d/20-xdebug.ini
echo Set CLI xdebug remote host to dockerhost.
fi
echo 'export PHP_IDE_CONFIG="serverName=popo.docker.amazee.io"' >> /var/www/drupal/.bash_envvars
echo 'alias xdebug-on="export XDEBUG_CONFIG=\"idekey=foobar\""' >> /var/www/drupal/.bashrc
sudo service php7.0-fpm restart
echo "xdebug settings updated, php restarted."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment