-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added xdebug.sh. Updated version of Xdebug for PHP 7.3. Updated READM…
…E.md. (#82)
- Loading branch information
Showing
6 changed files
with
125 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
zend_extension=xdebug.so | ||
;zend_extension=xdebug.so | ||
xdebug.max_nesting_level=500 | ||
xdebug.profiler_enable=0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
zend_extension=xdebug.so | ||
;zend_extension=xdebug.so | ||
xdebug.max_nesting_level=500 | ||
xdebug.profiler_enable=0 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#! /bin/bash | ||
|
||
# Grab full name of php container | ||
PHP_CONTAINER=$(docker ps | grep sugar-web1 | awk '{print $1}') | ||
|
||
getMyIP () | ||
{ | ||
local _ip _myip _line _nl=$'\n' | ||
while IFS=$': \t' read -a _line ;do | ||
[ -z "${_line%inet}" ] && | ||
_ip=${_line[${#_line[1]}>4?1:2]} && | ||
[ "${_ip#127.0.0.1}" ] && _myip=$_ip | ||
done< <(LANG=C /sbin/ifconfig) | ||
printf ${1+-v} $1 "%s${_nl:0:$[${#1}>0?0:1]}" $_myip | ||
} | ||
|
||
xdebug_status () | ||
{ | ||
echo 'xDebug status' | ||
docker exec -it $PHP_CONTAINER bash -c 'php -v' | ||
} | ||
|
||
xdebug_start () | ||
{ | ||
echo 'Start xDebug' | ||
|
||
# Uncomment line with xdebug extension, thus enabling it | ||
ON_CMD="sed -i 's/^;zend_extension=/zend_extension=/g' \ | ||
/usr/local/etc/php/conf.d/xdebug.ini" | ||
docker exec -it $PHP_CONTAINER bash -c "${ON_CMD}" | ||
|
||
if [[ "$1" == "change-ip" ]]; then | ||
# Grab IP address of eth0 | ||
IP=$(getMyIP) | ||
# Change IP address for parameter xdebug.remote_host | ||
IP_CMD="sed -i 's/^xdebug.remote_host=.*/xdebug.remote_host=$IP/g' \ | ||
/usr/local/etc/php/conf.d/xdebug.ini" | ||
docker exec -it $PHP_CONTAINER bash -c "${IP_CMD}" | ||
echo "New IP of remote_host: $IP" | ||
fi | ||
|
||
docker restart $PHP_CONTAINER | ||
docker exec -it $PHP_CONTAINER bash -c 'php -v' | ||
} | ||
|
||
xdebug_stop () | ||
{ | ||
echo 'Stop xDebug' | ||
|
||
# Comment out xdebug extension line | ||
OFF_CMD="sed -i 's/^zend_extension=/;zend_extension=/g' /usr/local/etc/php/conf.d/xdebug.ini" | ||
|
||
docker exec -it $PHP_CONTAINER bash -c "${OFF_CMD}" | ||
docker restart $PHP_CONTAINER | ||
docker exec -it $PHP_CONTAINER bash -c 'php -v' | ||
} | ||
|
||
case $1 in | ||
stop|STOP) | ||
xdebug_stop | ||
;; | ||
start|START) | ||
xdebug_start "$2" | ||
;; | ||
status|STATUS) | ||
xdebug_status | ||
;; | ||
*) | ||
echo "xDebug [Stop | Start | Status] in the ${PHP_FPM_CONTAINER} container." | ||
echo "xDebug must have already been installed." | ||
echo "Usage:" | ||
echo " .php/xdebug stop|start|status" | ||
|
||
esac | ||
|
||
exit 1 |