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.

36 lines
1.4 KiB

  1. #!/bin/bash
  2. # Not working on windows symlinks
  3. DIR="$(realpath $(dirname "$(readlink -f "$0")")/..)"
  4. PHP_VERSION=$1 # Without dot
  5. WITH_PROFILER=$2
  6. if [[ -z "${PHP_VERSION}" ]]; then PHP_VERSION=81; fi
  7. PHP_FPM_CONTAINER=$(docker ps | grep "php${PHP_VERSION}" | awk '{print $1}')
  8. WORKSPACE_CONTAINER=$(docker ps | grep "workspace${PHP_VERSION}" | awk '{print $1}')
  9. PHP_FPM_XDEBUG_EXT_PATH=/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
  10. WORKSPACE_XDEBUG_EXT_PATH=/etc/php/${PHP_VERSION}/cli/conf.d/20-xdebug.ini
  11. SED_XDEBUG_ON="sed -i 's/^;zend_extension=/zend_extension=/g'"
  12. docker exec -it "${PHP_FPM_CONTAINER}" bash -c "${SED_XDEBUG_ON} ${PHP_FPM_XDEBUG_EXT_PATH}"
  13. docker exec -it "${WORKSPACE_CONTAINER}" bash -c "${SED_XDEBUG_ON} ${WORKSPACE_XDEBUG_EXT_PATH}"
  14. echo "Choice PHP_VERSION: $PHP_VERSION"
  15. if [ "${PHP_VERSION}" -ne 74 ]; then
  16. if [ -n "${WITH_PROFILER}" ]; then
  17. SED_DEBUG_OR_PROFILER_MODE_ON="sed -i 's/^xdebug.profiler_enable=.*/xdebug.profiler_enable=1/g'"
  18. fi
  19. else
  20. if [ -n "${WITH_PROFILER}" ]; then
  21. SED_DEBUG_OR_PROFILER_MODE_ON="sed -i 's/^xdebug.mode=.*/xdebug.mode=profile/g'"
  22. else
  23. SED_DEBUG_OR_PROFILER_MODE_ON="sed -i 's/^xdebug.mode=.*/xdebug.mode=debug/g'"
  24. fi
  25. fi
  26. docker exec -it "${PHP_FPM_CONTAINER}" bash -c "${SED_DEBUG_OR_PROFILER_MODE_ON} ${PHP_FPM_XDEBUG_EXT_PATH}"
  27. docker exec -it "${WORKSPACE_CONTAINER}" bash -c "${SED_DEBUG_OR_PROFILER_MODE_ON} ${WORKSPACE_XDEBUG_EXT_PATH}"