You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

68 lines
1.6 KiB

  1. #! /bin/bash
  2. # NOTE: At the moment, this has only been confirmed to work with PHP 7
  3. PHP_VERSION=$2 # Without dot
  4. # Grab full name of workspace container
  5. WORKSPACE_CONTAINER=$(docker ps | grep workspace${PHP_VERSION} | awk '{print $1}')
  6. if [[ -z "${WORKSPACE_CONTAINER}" ]]; then
  7. echo "Unable to find workspace container: workspace${PHP_VERSION}"
  8. exit 1
  9. fi
  10. xdebug_status ()
  11. {
  12. echo 'xDebug status'
  13. docker exec -it $WORKSPACE_CONTAINER bash -c 'php -v'
  14. }
  15. xdebug_start ()
  16. {
  17. echo 'Start xDebug'
  18. # And uncomment line with xdebug extension, thus enabling it
  19. ON_CMD='sed -i "s/^;zend_extension=/zend_extension=/g" /etc/php/$PHP_VERSION/cli/conf.d/20-xdebug.ini'
  20. docker exec -it $WORKSPACE_CONTAINER bash -c "${ON_CMD}"
  21. docker exec -it $WORKSPACE_CONTAINER bash -c 'php -v'
  22. echo 'In cli use this for resolve hostname for debugger in your IDE:'
  23. echo 'export PHP_IDE_CONFIG="serverName=loc.mydomain.ru"'
  24. }
  25. xdebug_stop ()
  26. {
  27. echo 'Stop xDebug'
  28. # Comment out xdebug extension line
  29. OFF_CMD='sed -i "s/^zend_extension=/;zend_extension=/g" /etc/php/$PHP_VERSION/cli/conf.d/20-xdebug.ini'
  30. docker exec -it $WORKSPACE_CONTAINER bash -c "${OFF_CMD}"
  31. docker exec -it $WORKSPACE_CONTAINER bash -c 'php -v'
  32. }
  33. case $1 in
  34. stop|STOP)
  35. xdebug_stop
  36. ;;
  37. start|START)
  38. xdebug_start
  39. ;;
  40. status|STATUS)
  41. xdebug_status
  42. ;;
  43. *)
  44. echo "xDebug [Stop | Start | Status] in the ${WORKSPACE_CONTAINER} container."
  45. echo "xDebug must have already been installed."
  46. echo "Usage:"
  47. echo " .php-fpm/xdebug stop|start|status"
  48. esac
  49. exit 1