2016-08-15 16:59:29 +02:00
|
|
|
#! /bin/bash
|
|
|
|
|
2016-08-19 02:05:36 +02:00
|
|
|
# NOTE: At the moment, this has only been confirmed to work with PHP 7
|
2016-08-15 16:59:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
# Grab full name of php-fpm container
|
2017-03-16 00:51:54 +01:00
|
|
|
PHP_FPM_CONTAINER=$(docker ps | grep php-fpm | awk '{print $1}')
|
2016-08-15 16:59:29 +02:00
|
|
|
|
2016-08-31 13:52:03 +02:00
|
|
|
|
|
|
|
# Grab OS type
|
|
|
|
if [[ "$(uname)" == "Darwin" ]]; then
|
|
|
|
OS_TYPE="OSX"
|
|
|
|
else
|
|
|
|
OS_TYPE=$(expr substr $(uname -s) 1 5)
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2016-08-15 16:59:29 +02:00
|
|
|
xdebug_status ()
|
|
|
|
{
|
|
|
|
echo 'xDebug status'
|
|
|
|
|
|
|
|
# If running on Windows, need to prepend with winpty :(
|
2016-08-31 13:52:03 +02:00
|
|
|
if [[ $OS_TYPE == "MINGW" ]]; then
|
2016-08-15 16:59:29 +02:00
|
|
|
winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
|
|
|
|
|
|
|
else
|
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2016-08-31 13:52:03 +02:00
|
|
|
|
2016-08-15 16:59:29 +02:00
|
|
|
xdebug_start ()
|
|
|
|
{
|
|
|
|
echo 'Start xDebug'
|
|
|
|
|
|
|
|
# And uncomment line with xdebug extension, thus enabling it
|
|
|
|
ON_CMD="sed -i 's/^;zend_extension=/zend_extension=/g' \
|
2020-09-24 02:52:14 +02:00
|
|
|
/usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
|
2016-08-15 16:59:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
# If running on Windows, need to prepend with winpty :(
|
2016-08-31 13:52:03 +02:00
|
|
|
if [[ $OS_TYPE == "MINGW" ]]; then
|
2016-08-15 16:59:29 +02:00
|
|
|
winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${ON_CMD}"
|
|
|
|
docker restart $PHP_FPM_CONTAINER
|
|
|
|
winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
|
|
|
|
|
|
|
else
|
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c "${ON_CMD}"
|
|
|
|
docker restart $PHP_FPM_CONTAINER
|
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2016-08-31 13:52:03 +02:00
|
|
|
|
2016-08-15 16:59:29 +02:00
|
|
|
xdebug_stop ()
|
|
|
|
{
|
|
|
|
echo 'Stop xDebug'
|
|
|
|
|
|
|
|
# Comment out xdebug extension line
|
2020-09-24 02:52:14 +02:00
|
|
|
OFF_CMD="sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini"
|
2016-08-15 16:59:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
# If running on Windows, need to prepend with winpty :(
|
2016-08-31 13:52:03 +02:00
|
|
|
if [[ $OS_TYPE == "MINGW" ]]; then
|
2016-08-15 16:59:29 +02:00
|
|
|
# This is the equivalent of:
|
|
|
|
# winpty docker exec -it laradock_php-fpm_1 bash -c 'bla bla bla'
|
|
|
|
# Thanks to @michaelarnauts at https://github.com/docker/compose/issues/593
|
|
|
|
winpty docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}"
|
|
|
|
docker restart $PHP_FPM_CONTAINER
|
|
|
|
#docker-compose restart php-fpm
|
|
|
|
winpty docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
|
|
|
|
|
|
|
else
|
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c "${OFF_CMD}"
|
|
|
|
# docker-compose restart php-fpm
|
|
|
|
docker restart $PHP_FPM_CONTAINER
|
|
|
|
docker exec -it $PHP_FPM_CONTAINER bash -c 'php -v'
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
case $@ in
|
|
|
|
stop|STOP)
|
|
|
|
xdebug_stop
|
|
|
|
;;
|
|
|
|
start|START)
|
|
|
|
xdebug_start
|
|
|
|
;;
|
|
|
|
status|STATUS)
|
|
|
|
xdebug_status
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "xDebug [Stop | Start | Status] in the ${PHP_FPM_CONTAINER} container."
|
|
|
|
echo "xDebug must have already been installed."
|
|
|
|
echo "Usage:"
|
2017-04-20 19:55:09 +02:00
|
|
|
echo " .php-fpm/xdebug stop|start|status"
|
2016-08-15 16:59:29 +02:00
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 1
|