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.

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