|
|
@ -3,6 +3,7 @@ |
|
|
|
# NOTE: At the moment, this has only been confirmed to work with PHP 7 |
|
|
|
|
|
|
|
PHP_VERSION=$2 # Without dot |
|
|
|
WITH_PROFILER=$3 |
|
|
|
|
|
|
|
# Grab full name of php-fpm container |
|
|
|
PHP_FPM_CONTAINER=$(docker ps | grep php${PHP_VERSION} | awk '{print $1}') |
|
|
@ -12,6 +13,10 @@ if [[ -z "${PHP_FPM_CONTAINER}" ]]; then |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
if [[ ! -z "${WITH_PROFILER}" ]]; then |
|
|
|
echo "With profiler option". |
|
|
|
fi |
|
|
|
|
|
|
|
# Grab OS type |
|
|
|
if [[ "$(uname)" == "Darwin" ]]; then |
|
|
|
OS_TYPE="OSX" |
|
|
@ -43,6 +48,7 @@ xdebug_start () |
|
|
|
ON_CMD="sed -i 's/^;zend_extension=/zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" |
|
|
|
REMOTE_AUTOSTART_CMD="sed -i 's/^xdebug.remote_autostart=0/xdebug.remote_autostart=1/g' /usr/local/etc/php/conf.d/xdebug.ini" |
|
|
|
REMOTE_ENABLE_CMD="sed -i 's/^xdebug.remote_enable=0/xdebug.remote_enable=1/g' /usr/local/etc/php/conf.d/xdebug.ini" |
|
|
|
PROFILER_ENABLE_CDM="sed -i 's/^xdebug.profiler_enable=0/xdebug.profiler_enable=1/g' /usr/local/etc/php/conf.d/xdebug.ini" |
|
|
|
|
|
|
|
# If running on Windows, need to prepend with winpty :( |
|
|
|
if [[ $OS_TYPE == "MINGW" ]]; then |
|
|
@ -52,12 +58,19 @@ xdebug_start () |
|
|
|
docker restart $PHP_FPM_CONTAINER |
|
|
|
winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' |
|
|
|
|
|
|
|
if [[ ! -z "${WITH_PROFILER}" ]]; then |
|
|
|
winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${PROFILER_ENABLE_CDM}" |
|
|
|
fi |
|
|
|
else |
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c "${ON_CMD}" |
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_AUTOSTART_CMD}" |
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_ENABLE_CMD}" |
|
|
|
docker restart $PHP_FPM_CONTAINER |
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' |
|
|
|
|
|
|
|
if [[ ! -z "${WITH_PROFILER}" ]]; then |
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c "${PROFILER_ENABLE_CDM}" |
|
|
|
fi |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
@ -70,6 +83,7 @@ xdebug_stop () |
|
|
|
OFF_CMD="sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" |
|
|
|
REMOTE_AUTOSTART_CMD="sed -i 's/^xdebug.remote_autostart=1/xdebug.remote_autostart=0/g' /usr/local/etc/php/conf.d/xdebug.ini" |
|
|
|
REMOTE_ENABLE_CMD="sed -i 's/^xdebug.remote_enable=1/xdebug.remote_enable=0/g' /usr/local/etc/php/conf.d/xdebug.ini" |
|
|
|
PROFILER_DISABLE_CMD="sed -i 's/^xdebug.profiler_enable=1/xdebug.profiler_enable=0/g' /usr/local/etc/php/conf.d/xdebug.ini" |
|
|
|
|
|
|
|
# If running on Windows, need to prepend with winpty :( |
|
|
|
if [[ $OS_TYPE == "MINGW" ]]; then |
|
|
@ -82,7 +96,7 @@ xdebug_stop () |
|
|
|
docker restart $PHP_FPM_CONTAINER |
|
|
|
#docker-compose restart php-fpm |
|
|
|
winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' |
|
|
|
|
|
|
|
winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${PROFILER_DISABLE_CMD}" |
|
|
|
else |
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}" |
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c "${REMOTE_AUTOSTART_CMD}" |
|
|
@ -90,6 +104,7 @@ xdebug_stop () |
|
|
|
# docker-compose restart php-fpm |
|
|
|
docker restart $PHP_FPM_CONTAINER |
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v' |
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c "${PROFILER_DISABLE_CMD}" |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|