Turn PHP Xdebug profiling on and off by BASH script

It was bugging me (debugging me?) that Xdebug profiling dragged my development server down so much. So here’s a simple script to place in /usr/local/bin to turn it off and on more easily. Remember to chmod +x it first.

This works fine on Ubuntu.

#!/bin/bash
# Simple script to enable or disable xdebug profiling

case $1 in
  on)
    sudo sed -i 's/xdebug.profiler_enable=0/xdebug.profiler_enable=1/g' /etc/php5/conf.d/xdebug.ini
    sudo service apache2 restart
  ;;
  off)
    sudo sed -i 's/xdebug.profiler_enable=1/xdebug.profiler_enable=0/g' /etc/php5/conf.d/xdebug.ini
    sudo service apache2 restart
  ;;
  *)
    echo "Usage: php_debug on|off"
  ;;
esac

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>